When I hear Bash/Perl/Ruby/Java/C/ML/Erlang/Smalltalk/etc I know what I'm dealing with, I know what they are good for and when to use them, but what about List? Don't get me wrong, I like Lisp, I just don't see for what I could use it.
So, what are you doing with Lisp and why exactly Lisp over any other PL?
Name:
Anonymous2007-07-26 10:18 ID:AYkKzNh1
Lisp is also excellent for abstraction and good at eradicating code duplication
(Really simple example)
Let's say I have a function print-customer-info that takes a list containing customer information and prints it out nicely.
In a general sense, what I am doing is mapping the values of a list to some variables. But I really don't want to manually type out that for every single variable, do I?
So I can write a macro let-from-list that does this for me, so the code then looks more like this:
(define (print-customer-info customer-info)
(let-from-list (customer-info) (name age street sex)
(display (string-append "Name: " name "\n"
"Age: " (number->string age) "\n"
"Street: " street "\n"
"Sex: " sex "\n"))))
Which is a lot nicer. Of course, there's already a simple way to do this in Scheme. But the point is, if it wasn't built-in, I could add it myself.