mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 22:17:33 +02:00
WIP
This commit is contained in:
parent
a3f47819df
commit
cd85a7ddde
1 changed files with 26 additions and 1 deletions
27
opt-test.scm
27
opt-test.scm
|
@ -7,7 +7,7 @@
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
(scheme write)
|
(scheme write)
|
||||||
(scheme read))
|
(scheme read))
|
||||||
(let ((x (read))
|
#;(let ((x (read))
|
||||||
(y (read))
|
(y (read))
|
||||||
(z (read))
|
(z (read))
|
||||||
(iterations 10000000)
|
(iterations 10000000)
|
||||||
|
@ -17,3 +17,28 @@
|
||||||
(set! sum (+ sum sum (* x y z)))
|
(set! sum (+ sum sum (* x y z)))
|
||||||
(set! sum (- sum sum (* x y z))))
|
(set! sum (- sum sum (* x y z))))
|
||||||
(write sum))
|
(write sum))
|
||||||
|
|
||||||
|
;; Take an expression containing a single function call and break it up
|
||||||
|
;; into many calls of 2 arguments each.
|
||||||
|
(define (->dyadic expr)
|
||||||
|
(cond
|
||||||
|
((< (length expr) 4)
|
||||||
|
expr)
|
||||||
|
(else
|
||||||
|
(let ((fnc (car expr)))
|
||||||
|
(foldl
|
||||||
|
(lambda (x acc)
|
||||||
|
(list fnc acc x))
|
||||||
|
`(,fnc ,(cadr expr) ,(caddr expr))
|
||||||
|
(cdddr expr))))))
|
||||||
|
|
||||||
|
(write (->dyadic '(+ 1)))
|
||||||
|
(write (->dyadic '(+ 1 2)))
|
||||||
|
(write (->dyadic '(+ 1 2 3)))
|
||||||
|
(write (->dyadic '(+ 1 2 3 4)))
|
||||||
|
;(write
|
||||||
|
; (foldl
|
||||||
|
; (lambda (x acc)
|
||||||
|
; (list 'Cyc-fast-plus acc x))
|
||||||
|
; '(Cyc-fast-plus 1 2)
|
||||||
|
; '(3 4 5)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue