Solved

Trivial question on Lisp. Getting string length

Posted on 2003-10-28
8
303 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

825 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