Mark J. Reed markjreed-at-gmail.com |Perl 6| wrote:
In Haskell it may be called fold (well, foldl and foldr), but the concept
has has a variety of names.  Two of the more common ones are "reduce" and
"inject"; I believe Perl6 chose "reduce" for consistency with the Perl5
List::Util module.  Common Lisp and Python also call it "reduce":

(defun ! (n)
     (reduce #'* (loop for i from 1 to n collecting i)))


def fact(n):
     return reduce(lambda x,y: x*y, range(1,n+1))


While Ruby calls it "inject".


def fact(n)
   (1..n).inject { |x,y| x*y }
end



And APL calls it "|ยจ" (two little dots high up)
|

Reply via email to