LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-27-2004, 05:15 PM   #1
Hady
Member
 
Registered: Nov 2003
Posts: 55

Rep: Reputation: 15
Sorting a list of words in LISP!


hi!

how can i sort a list of WORDS in LISP?

(is there any function in LISP that is equivalent to C++'s strcmp?)
(can i get the ASCII code of a character in LISP?)

thank you
 
Old 05-01-2004, 04:29 PM   #2
eric.r.turner
Member
 
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint Debian Edition (LMDE)
Posts: 215

Rep: Reputation: 31
ANSI Common Lisp has a sort function and a few string comparison functions.

Code:
(sort sequence predicate &key key)
(string< string1 string2 &key start1 end1 start2 end2)
(string> string1 string2 &key start1 end1 start2 end2)
(string-greaterp string1 string2 &key start1 end1 start2 end2)
(string-lessp string1 string2 &key start1 end1 start2 end2)
To sort a list of strings in ascending order try this:

Code:
(sort '("foo" "baz" "bar") #'string-lessp)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Replace: Asian Words to English Words ieeestd802 Linux - Software 0 10-27-2004 08:48 PM
Lisp phoenix7 Programming 4 09-24-2004 08:40 AM
Gnome panel - window list (sorting) dnar Linux - General 0 06-06-2004 11:41 PM
This might sound strange, but I need a big list of dirty words. Travis86 Programming 12 07-18-2003 12:06 AM
Lisp, emacs-lisp aizkorri Programming 1 09-04-2002 07:16 PM


All times are GMT -5. The time now is 08:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration