Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
16
Task/Function-composition/LFE/function-composition-1.lfe
Normal file
16
Task/Function-composition/LFE/function-composition-1.lfe
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
(defun compose (f g)
|
||||
(lambda (x)
|
||||
(funcall f
|
||||
(funcall g x))))
|
||||
|
||||
(defun compose (funcs)
|
||||
(lists:foldl #'compose/2
|
||||
(lambda (x) x)
|
||||
funcs))
|
||||
|
||||
(defun check ()
|
||||
(let* ((sin-asin (compose #'math:sin/1 #'math:asin/1))
|
||||
(expected (math:sin (math:asin 0.5)))
|
||||
(compose-result (funcall sin-asin 0.5)))
|
||||
(io:format '"Expected answer: ~p~n" (list expected))
|
||||
(io:format '"Answer with compose: ~p~n" (list compose-result))))
|
||||
13
Task/Function-composition/LFE/function-composition-2.lfe
Normal file
13
Task/Function-composition/LFE/function-composition-2.lfe
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
> (funcall (compose #'math:sin/1 #'math:asin/1)
|
||||
0.5)
|
||||
0.49999999999999994
|
||||
> (funcall (compose `(,#'math:sin/1
|
||||
,#'math:asin/1
|
||||
,(lambda (x) (+ x 1))))
|
||||
0.5)
|
||||
1.5
|
||||
> (check)
|
||||
Expected answer: 0.49999999999999994
|
||||
Answer with compose: 0.49999999999999994
|
||||
ok
|
||||
>
|
||||
Loading…
Add table
Add a link
Reference in a new issue