ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
don't run too fast, lisp is propaply most different programing language you may come around. it's different, very different from java, c, c++ etc. Python has some similarities, javascript, too. in the end lisp has completely different philosophy behind it. i found Lisp by Winston, Patrick Henry very helpful when i learned lisp.
my biggest advice would be take it slow. don't jump to CLOS right away. take your time understand main lisp ideas. it will take some time (it ate my one bloody semester. i failed a lot of classes that semester ), when you do, CLOS will come easy.
don't run too fast, lisp is propaply most different programing language you may come around. it's different, very different from java, c, c++ etc. Python has some similarities, javascript, too. in the end lisp has completely different philosophy behind it. i found Lisp by Winston, Patrick Henry very helpful when i learned lisp.
my biggest advice would be take it slow. don't jump to CLOS right away. take your time understand main lisp ideas. it will take some time (it ate my one bloody semester. i failed a lot of classes that semester ), when you do, CLOS will come easy.
I would word it stronger - jumping on OO wagon too early may deprive the learner from the chance to realize that in functional languages many OO complexities/annoyances are not needed in the first place.
I would word it stronger - jumping on OO wagon too early may deprive the learner from the chance to realize that in functional languages many OO complexities/annoyances are not needed in the first place.
i didn't want to scare a possible future lisp programmer. by the way, you know you can do OO with only function
i didn't want to scare a possible future lisp programmer. by the way, you know you can do OO with only function
I more and more prefer functional and have never been a big fan of OO. I think it is proven mathematically that OO can be implemented through functional, and I think I once found an article explaining this in detail.
I more and more prefer functional and have never been a big fan of OO. I think it is proven mathematically that OO can be implemented through functional, and I think I once found an article explaining this in detail.
so, back to my original question. I would like to program a very simple card game. I'm hesitant to describe it because in the past answers to my questions here have been "here is the whole code" which is very discouraging when you're trying to do it yourself.
OK: so ignoring objects and CLOS, what is the best mechanism for representing a "thing" in lisp? Should I use a list?
I want a deck of cards, basically. Then I can work out what to do with them later. Is this approach: http://code.tumyr.org/lisp/poker/cards.lisp a decent one?
(Note to self: "card in lisp" is a google search with many non-relevant results, "deck of cards in lisp" is a better search string.)
I found lisperati an interesting read- and am considering the text-adventure: could be fun.
I want to program a game in Lisp that uses extremely simple AI to give me a chance at not hyper-ventilating over my AI pracs (in lisp) next semester.
...
OK: so ignoring objects and CLOS, what is the best mechanism for representing a "thing" in lisp? Should I use a list?[/i]
...
TG
I myself am very new to LISP, but from experience with Perl I can tell you that objects are best represented as scopes into which interrelated datum and functions are encapsulated, with, as necessary, usage of closures.
Regarding data representation - look at 'cond' construct too - to me it looks kind of like hash in Perl (in a sense), i.e. if I understand correctly, it is possible to imitate access to hash table using "key" as input and getting its "value" as output. Probably LISP macro mechanism can be used to add "key" "value" pairs.
Sorry Sergei- I don't know Perl, so have little idea of what you just said.
Especially this sentence:
Thanks for the link though.
TG
OK, then think about anonymous classes in Java. They encapsulate. And, IMO, by default scopes/classes should be anonymous - in order to avoid name clashes.
OK: so ignoring objects and CLOS, what is the best mechanism for representing a "thing" in lisp? Should I use a list?
I want a deck of cards, basically. Then I can work out what to do with them later. Is this approach: http://code.tumyr.org/lisp/poker/cards.lisp a decent one?
I would probably use defstruct, but the specific representation doesn't really matter as long as the abstract interface is used (create-card, card-value, card-suit, ...).
Quote:
Originally Posted by Sergei Steshenko
Regarding data representation - look at 'cond' construct too - to me it looks kind of like hash in Perl (in a sense), i.e. if I understand correctly, it is possible to imitate access to hash table using "key" as input and getting its "value" as output. Probably LISP macro mechanism can be used to add "key" "value" pairs.
cond is more like an "if else if ... else" conditional construct. Common Lisp has hashtables as well as the more traditional Lisp Association Lists.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.