Solved

Trivial question on Lisp. Getting string length

Posted on 2003-10-28
8
311 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Make the most of your online learning experience.
Simple Linear Regression
Starting up a Project

634 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