You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thanks for making polished website with good material to get started. Sorry if this is a beginner misunderstanding and not a real issue, but I think the reduce example is the wrong order, on https://lisp-lang.org/learn/lists
(reduce #'(lambda (a b)
(* a b))
(list 10 20 30))
The above is equivalent to (* 10 (* 20 (* 30)))
Those parens would mean reduce is like a right fold, calling f (first element) (reduce f (rest of list))
where it seems it is a left fold, as the next example shows, calling f (first element) (second element), then f (result of that) (third element)...
To double check I switched it to division instead of multiplication so that the associativity matters:
(reduce #'(lambda (a b)
(/ a b))
(list 10 20 30))
I get 1/60 like in (/ (/ 10 20) 30)
so I'm pretty sure the explanation should be (* (* 10 20) 30) and not (* 10 (* 20 (* 30)))
The text was updated successfully, but these errors were encountered:
thanks for making polished website with good material to get started. Sorry if this is a beginner misunderstanding and not a real issue, but I think the reduce example is the wrong order, on https://lisp-lang.org/learn/lists
Those parens would mean reduce is like a right fold, calling f (first element) (reduce f (rest of list))
where it seems it is a left fold, as the next example shows, calling f (first element) (second element), then f (result of that) (third element)...
To double check I switched it to division instead of multiplication so that the associativity matters:
I get 1/60 like in
(/ (/ 10 20) 30)
so I'm pretty sure the explanation should be
(* (* 10 20) 30)
and not(* 10 (* 20 (* 30)))
The text was updated successfully, but these errors were encountered: