LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 04: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, 03:29 PM   #2
eric.r.turner
Member
 
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint
Posts: 216

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



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 07:48 PM
Lisp phoenix7 Programming 4 09-24-2004 07:40 AM
Gnome panel - window list (sorting) dnar Linux - General 0 06-06-2004 10:41 PM
This might sound strange, but I need a big list of dirty words. Travis86 Programming 12 07-17-2003 11:06 PM
Lisp, emacs-lisp aizkorri Programming 1 09-04-2002 06:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:15 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
Open Source Consulting | Domain Registration