Posts

Showing posts from January 25, 2009

Why Lisp Do Not Have A Generic Copy-List Function

perm url: http://xahlee.org/UnixResource_dir/writ/lisp_equal_copy_list.htmlXah Lee, 2009-01-29Dear lispers,LOL.There's is a paper by Kent Pitman, about something about why lisp doesn't have copy or the complexities of meaning of equality. This essay is often cited by lispers in comp.lang.lisp, about every few months in the past 9 years.The current url is here: http://www.nhplace.com/kent/PS/EQUAL.htmlI became aware of this essay maybe in early 2000s. I actually never red it. I just knew that it's something lisper quote frequently like a gospel. In the back of my mind, i tend to think it is something particular to lisp, and thus is stupid, because many oft-debated lisp issues, never happens in Mathematica, nor any dynamic langs i have become a expert of since 2000. (e.g. perl, python, php, javascript.).Today, out of boredom, i went and took a look (it has been just cited again, by a old-time lisper Rob Warnock). I thought: let's see what would happen, and perhaps it wou…

function application is not currying

perm url: http://xahlee.org/UnixResource_dir/writ/apply_func_examples.htmlIn Jon Harrop's book Ocaml for Scientist at http://www.ffconsultancy.com/products/ocaml_for_scientists/chapter1.html It says:CurryingA curried function is a function which returns a function as its result.LOL. That is incorrect.Here are some examples of a function that returns a function as result, but is not currying.Mathematica example: f[n_]:=Function[n^#]; f[7][2] (* returns 49 *) Emacs lisp example: (defmacrof (n) (list 'lambda (list 'x) (list 'expt n 'x) ) ) (funcall (f 7) 2) Perl example:subf {$n=$_[0]; sub { $n ** $_[0]} }; print &{ f(7) } (2); Javascript example:functionf(n) {returnfunction (x) {return Math.pow(x,n);}; } alert (f(7) (2)); In the above, a function returns a function, and the result function is applied to a value. They demonstrate 2 things:The ability of the lang to have a function that returns a function.The ability to apply a value (of type function) to a value.T…