oops, faster

master
Matthew Butterick 4 years ago
parent bc77b0e75f
commit 3a72140709

@ -6,14 +6,17 @@
(apply append (map (curry make-list (add1 i)) '(0 1 0 -1))))) (apply append (map (curry make-list (add1 i)) '(0 1 0 -1)))))
(define (fft str [phase-count 1]) (define (fft str [phase-count 1])
(for/fold ([ints (for/list ([c (in-string str)]) (define ints (for/list ([c (in-string str)])
(string->number (string c)))] (string->number (string c))))
(define patintss (make-patintss ints))
(time
(for/fold ([ints ints]
#:result (take ints 8)) #:result (take ints 8))
([pidx (in-range phase-count)]) ([pidx (in-range phase-count)])
(for/list ([patints (in-list (make-patintss ints))]) (for/list ([patints (in-list patintss)])
(modulo (abs (for/sum ([int (in-list (cons 0 ints))] ; cons 0 to burn off first patint (modulo (abs (for/sum ([int (in-list (cons 0 ints))] ; cons 0 to burn off first patint
[patint (in-cycle patints)]) [patint (in-cycle patints)])
(* int patint))) 10)))) (* int patint))) 10)))))
(check-equal? (fft "80871224585914546619083218645595" 100) '(2 4 1 7 6 1 7 6)) (check-equal? (fft "80871224585914546619083218645595" 100) '(2 4 1 7 6 1 7 6))