Higher-order functions: Difference between revisions

m
→‎{{header|Common Lisp}}: Added a few more examples related to CL library that accept function arguments.
m (→‎{{header|REXX}}: removed superflous blanks. -- ~~~~)
m (→‎{{header|Common Lisp}}: Added a few more examples related to CL library that accept function arguments.)
Line 509:
CL-USER> (call-it #'add 1 2)
3</lang>
The Common Lisp library makes extensive use of higher-order functions:
<pre>CL-USER> (funcall #'+ 1 2 3)
6
CL-USER> (apply #'+ (list 1 2 3))
6
CL-USER> (sort (string-downcase "Common Lisp will bend your mind!") #'string<)
" !bcddeiiilllmmmnnnoooprsuwy"
CL-USER> (reduce #'/ '(1 2 3 4 5))
1/120
CL-USER> (mapcar #'(lambda (n) (expt 2 n)) '(0 1 2 3 4 5))
(1 2 4 8 16 32)
CL-USER> </pre>
 
=={{header|D}}==
Anonymous user