Solved

Trivial question on Lisp. Getting string length

Posted on 2003-10-28
8
308 Views
Last Modified: 2010-05-18
Is there a build-in function in lisp to return the length of a string?
If there isn't what are the ways in getting it?
0
Comment
Question by:klackons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 69

Expert Comment

by:Callandor
ID: 9641730
I think the function you want is string-length
0
 

Author Comment

by:klackons
ID: 9641816
well.. string-length didn't work..
but i managed to find it on the web. The function I was looking for is (length string)
thanx anyway...

However now I have another question and that is can there be a AND/OR condition when defining the condition in the (cond ) function??
0
 
LVL 69

Expert Comment

by:Callandor
ID: 9642280
I don't see why not - a condition is not limited to a single test, and Lisp is known for its nested structures.  It's been a while since I actually coded in Lisp, though.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:klackons
ID: 9642314
can u pls show me some examples?
let say i want to have a simple AND condition like:

if (A = 1 and B = 1)
  print (stuff)

how should i code this in clisp?
0
 
LVL 14

Expert Comment

by:Tommy Kinard
ID: 9642383
(strlen string) for acad2000i

The cond function can be used like a case select statement:
(cond
     ((= s 1) "Y")
     ((= s 2) "N")
     ((= s 3) "T")
     ((= s 4) "P")
)

I would need a smple set of data to setup the cond.

HTH
dragontooth

0
 
LVL 69

Accepted Solution

by:
Callandor earned 50 total points
ID: 9642756
>if (A = 1 and B = 1)
>  print (stuff)

((and (equal A 1) (equal B 1)) (print stuff))
0
 

Author Comment

by:klackons
ID: 9642817
thanx callandor for the quick reply, that was what I needed to know..
One last question, does that mean 'OR' will work as well?

meaning: ((or (equal A 1) (equal B 1)) (print stuff))

is possible as well?
0
 
LVL 69

Expert Comment

by:Callandor
ID: 9643279
Correct.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question