Skip to content

Commit

Permalink
Simplifying lines
Browse files Browse the repository at this point in the history
  • Loading branch information
cbowdon committed Mar 14, 2012
1 parent 004c9cc commit f84ab8a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
8 changes: 2 additions & 6 deletions fannkuch-redux-test.rkt
Expand Up @@ -33,11 +33,6 @@
(call-with-input-file "fannkuch-redux-permutations.txt"
parse-example-file))


(require profile)

(profile-thunk (λ () (for-each fannkuch permutations)))

(test-case
"flipping works"
(check-equal? (map (λ (x) (car (fannkuch x))) input) output))
Expand All @@ -47,7 +42,8 @@
(check-equal? (fannkuch-checksum permutations) 228))



(require profile)
(profile-thunk (λ () (fannkuch-checksum permutations)))



5 changes: 1 addition & 4 deletions fannkuch-redux.rkt
Expand Up @@ -28,8 +28,5 @@
(define (fc-iter loi sum index)
(if [null? loi]
sum
(let ([count (cdr (fannkuch (car loi)))])
(if [even? index]
(fc-iter (cdr loi) (+ sum count) (add1 index))
(fc-iter (cdr loi) (- sum count) (add1 index))))))
(fc-iter (cdr loi) ((if (even? index) + -) sum (cdr (fannkuch (car loi)))) (add1 index))))
(fc-iter listofinput 0 0))

0 comments on commit f84ab8a

Please sign in to comment.