Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/First-class-functions/Ol/first-class-functions.ol
Normal file
13
Task/First-class-functions/Ol/first-class-functions.ol
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
; creation of new function from preexisting functions at run-time
|
||||
(define (compose f g) (lambda (x) (f (g x))))
|
||||
|
||||
; storing functions in collection
|
||||
(define (quad x) (* x x x x))
|
||||
(define (quad-root x) (sqrt (sqrt x)))
|
||||
|
||||
(define collection (tuple quad quad-root))
|
||||
|
||||
; use functions as arguments to other functions
|
||||
; and use functions as return values of other functions
|
||||
(define identity (compose (ref collection 2) (ref collection 1)))
|
||||
(print (identity 11211776))
|
||||
Loading…
Add table
Add a link
Reference in a new issue