Search found 20 matches

by Destruct1
Fri May 21, 2010 1:09 pm
Forum: Common Lisp
Topic: Only in Lisp
Replies: 43
Views: 41691

Re: Only in Lisp

Macros: Macros are to this day still unique to lisp (there are languages which employ macros, but there are either simple textreplacing macros like in C or in languages that are even more underground than Lisp). In Paul Grahams book "On Lisp" he desribes 3 things macros do that are imposs...
by Destruct1
Fri May 21, 2010 12:22 pm
Forum: Common Lisp
Topic: Only in Lisp
Replies: 43
Views: 41691

Re: Only in Lisp

I learned Lisp for 4 weeks and then switched to Python. This is a fairly long comparison. Syntax: Lisp syntax is very regular. It is basically a repetition of open_parens_( function_name/macro_name arg0_name arg1_name ... )_closing_parens Each argument is either a direct variable or another subexpre...
by Destruct1
Fri May 21, 2010 12:00 pm
Forum: Common Lisp
Topic: Only in Lisp
Replies: 43
Views: 41691

Re: Only in Lisp

For some reason Python doesn't allow the conditionals to be returned either.. if ... : ... else ... must be toplevel because the indentation requirement at least. Seems to me like a completely arbitrary restriction. Even C has ... ? ... : ... Python has a new ternary operator (if this is what you m...
by Destruct1
Mon Feb 22, 2010 6:31 am
Forum: Common Lisp
Topic: Libraries
Replies: 8
Views: 8794

Re: Libraries

I feel your pain I think the best solution is to use Lisp with a mature library from another language. Configure a foreign language interface and you are free for a lifetime. Ruby is good for the integrated Web framework, Python is useful all around and Java's library is just huge but uses the low-l...
by Destruct1
Mon Feb 22, 2010 6:03 am
Forum: Common Lisp
Topic: Lisp newbie: deck of cards in Lisp
Replies: 17
Views: 17128

Re: Lisp newbie: deck of cards in Lisp

I think this sort function is way more convinient than the compare x with y approach. Well, I get it, but, to be honest, I don't find it very convenient. You need to form the tuples, sort them and undo the tuples. The other version is faster and more intuitive. Not to mention that this one has a pr...
by Destruct1
Wed Feb 17, 2010 3:19 am
Forum: Common Lisp
Topic: Lisp newbie: deck of cards in Lisp
Replies: 17
Views: 17128

Re: Lisp newbie: deck of cards in Lisp

I meant something else: ;; first I take a list and a function and create a returnlist of the kind lst = ((x1 f(x1)) (x2 f(x2)) (x3 f(x3)) etc... ) (defun mapcarzip (func lst) (mapcar #'(lambda (d) (list d (funcall func d))) lst) ;; then I sort the list by the second number in each sublist (so by f(x...
by Destruct1
Tue Feb 16, 2010 3:34 am
Forum: Common Lisp
Topic: I dont get Macros
Replies: 31
Views: 40825

Re: I dont get Macros

DSL are important and arithmetic operations are not special. However it is possible to implement this kind of behavior in Python (and other languages) with operator overloading. from math import sqrt class Point (): def __init__ (self, x_=0, y_=0): self.x = x_ self.y = y_ def __getattr__ (self, attr...
by Destruct1
Tue Feb 16, 2010 2:16 am
Forum: Common Lisp
Topic: Lisp newbie: deck of cards in Lisp
Replies: 17
Views: 17128

Re: Lisp newbie: deck of cards in Lisp

Here is a basic framework (/ snippet of code): http://rosettacode.org/wiki/Playing_cards#Common_Lisp What I find a neat trick for shuffling is using a sort applicative operator with a random function as key. That is what I did above :) Good job :D I am not sure if I remember correctly but I think t...
by Destruct1
Mon Feb 15, 2010 4:08 am
Forum: Common Lisp
Topic: I dont get Macros
Replies: 31
Views: 40825

Re: I dont get Macros

Destruct1, you're right - example you gave - construction of the new program code during runtime and evaluation - is actually more expressive (although syntactically more complicated) than macros. The advantage of macros is, as it is already said, they allow compilation. That is the essence. If you...
by Destruct1
Mon Feb 15, 2010 2:00 am
Forum: Common Lisp
Topic: Lisp newbie: deck of cards in Lisp
Replies: 17
Views: 17128

Re: Lisp newbie: deck of cards in Lisp

Here is a basic framework (/ snippet of code):

http://rosettacode.org/wiki/Playing_cards#Common_Lisp

What I find a neat trick for shuffling is using a sort applicative operator with
a random function as key.