#### Archived

This topic is now archived and is closed to further replies.

# LISP help?

This topic is 5523 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Does anyone have LISP code for text to list input (for a text-based RPG)? All I really need is capability to understand string input--or at least parse it to lists! i.e.: Parse only: "Throw red rock hard at big ugly giant" ==> (Throw red rock hard at big ugly giant) True understanding: "Throw red rock hard at big ugly giant" ==> ((Throw hard) (rock red) at (giant big ugly)) The second part is just car/cdr/cons wrangling, though, and is actually easier for me! I really only have trouble with strings...read and write and concatenate oh my. Thank you very much! I know LISP isn''t really a "language of choice" for most people anymore but maybe somebody out there stuck with it.....

##### Share on other sites
Forget about text parsing right now. Just input using list format: (throw the red rock at the super ugly monster). That''s what is so great about Lisp, it let''s you forget about all the bullshit and get to the heart of the problem. When you''re done with the guts of your program, you''ll have the skills necessary to do the text parsing.

Seriously, do it the Lisp way. Bypass the text parsing right now, and just do it in list form.

##### Share on other sites
quote:
Original post by ofsinope
Does anyone have LISP code for text to list input (for a text-based RPG)?

Check out read-from-string''. E.g:
(read-from-string   (format nil "(~A)" "throw red rock hard at big ugly giant")) `

quote:

Thank you very much! I know LISP isn''t really a "language of choice" for most people anymore but maybe somebody out there stuck with it.....

Stuck with it?

##### Share on other sites
Maybe not the most elegant method to parse a string, but you can access strings char by char with AREF, you can retrieve parts of a string using SUBSEQ. MAP also works on strings.

##### Share on other sites
SabreMan: Hey, that''s pretty clever. Great idea! I think I''ll modify it just a bit and go with:

...just because format is such a monstrously bloated function.

BishopPass: I''ve been doing that so far, but EVERYONE doesn''t really need to know that it was written in lisp. Requiring parentheses make it so brutally obvious...
Diodor: Retch! As long as people don''t throw in any ran@#$!%^dom characters, I shouldn''t need to go to those extremes. Thanks y''all... #### Share this post ##### Link to post ##### Share on other sites quote: Diodor: Retch! As long as people don''t throw in any ran@#$!%^dom characters, I shouldn''t need to go to those extremes.

Is there any simple way to avoid the program crashing when the user does throw random characters at your program? If not, it seems to me that sooner or later you''ll have to give up on READing input.

##### Share on other sites
quote:
Original post by ofsinope
BishopPass: I''ve been doing that so far, but EVERYONE doesn''t really need to know that it was written in lisp. Requiring parentheses make it so brutally obvious...

So you''re totally done with the program then?

##### Share on other sites
quote:
Original post by bishop_pass
So you''re totally done with the program then?

Haha! I wish...I''m just getting started, really. But I have a few simple functions that handle the savegames and the world map...once they''re finished, you can have them if you want.

##### Share on other sites
quote:
Original post by ofsinope
Haha! I wish...I''m just getting started, really.

Ah Ha! You should be focusing on the semantics and guts, not the low level I/O.

##### Share on other sites
Snif. Don''t "Ah ha" me.

Hehe...look, the odds of me seeing this through to completion are rather low, just because I have so many more productive things that I need to do. I''m just puttering around and having fun.

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000027
×