>>2
I was kind of annoyed that all that line noise was necessary just to use reduceRight. One consequence of OOP is that functions are imprisoned inside classes but at least javascript provides .call to let you freely pass in "this" of your choice.
>>8
You're right, my toy languages are incapable of looking like such pigshit.
Name:
Anonymous2012-09-27 4:45
>>3 One consequence of OOP is that functions are imprisoned inside classes
Wrong. (defgeneric reduce-right (f xs x))
(defmethod reduce-right (f (xs sequence) x)
(reduce f xs :from-end t :initial-value x))
(reduce f xs :from-end t))
(defun compose (&rest fs)
(lambda (x)
(reduce-right #'funcall fs x)))
Actually, Common Lisp doesn't even requires you to use CLOS here since reduce is already parametrised for sequences. Please also note that if this were production code, a compiler macro would optimise away as much funcall calls as possible. Enjoy your toy language.