From f84ab8acc15349d8396a7e7350ca3e90008e98dc Mon Sep 17 00:00:00 2001 From: Chris Bowdon Date: Wed, 14 Mar 2012 19:36:02 +0100 Subject: [PATCH] Simplifying lines --- fannkuch-redux-test.rkt | 8 ++------ fannkuch-redux.rkt | 5 +---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/fannkuch-redux-test.rkt b/fannkuch-redux-test.rkt index b91f009..2807eec 100644 --- a/fannkuch-redux-test.rkt +++ b/fannkuch-redux-test.rkt @@ -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)) @@ -47,7 +42,8 @@ (check-equal? (fannkuch-checksum permutations) 228)) - +(require profile) +(profile-thunk (λ () (fannkuch-checksum permutations))) diff --git a/fannkuch-redux.rkt b/fannkuch-redux.rkt index 5d13fdf..335316a 100644 --- a/fannkuch-redux.rkt +++ b/fannkuch-redux.rkt @@ -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)) \ No newline at end of file