Google 그룹스는 더 이상 새로운 유즈넷 게시물 또는 구독을 지원하지 않습니다. 과거의 콘텐츠는 계속 볼 수 있습니다.

character Comparison

조회수 1회
읽지 않은 첫 메시지로 건너뛰기

Rainer Joswig

읽지 않음,
2000. 2. 20. 오전 3:00:0000. 2. 20.
받는사람
In article <mZLr4.9509$_e7.3...@news1.sshe1.sk.home.com>, "Chris H"
<newsgro...@NOJUNKhome.com> wrote:

> Hi all,
> I am a newbie in lisp programming ...

Make sure you have a Common Lisp reference handy.
The ANSI CL standard is available in a hypertextified
version. Another source of wisdom is CLtL2 (Common Lisp
the Language, 2nd edition) - also available as hypertext.
For more information about Lisp visit http://www.lisp.org .

> and
> I have a question on doing character comparison
> eg
>
> how do I check if character 'a' is in word 'banada'
>
> is any thing like substring() function ?


FIND item sequence &key :from-end :test :test-not :start
:end :key
[Function]
returns the first element in the specified portion of sequence that
matches item according to test, or nil if no element matches.


? (find #\a "BANANA" :test #'char=)
NIL

Rainer Joswig, ISION Internet AG, Harburger Schlossstraße 1,
21079 Hamburg, Germany, Tel: +49 40 77175 226
Email: rainer...@ision.de , WWW: http://www.ision.de/

Erik Naggum

읽지 않음,
2000. 2. 20. 오전 3:00:0000. 2. 20.
받는사람
* "Chris H" <newsgro...@NOJUNKhome.com>

| how do I check if character 'a' is in word 'banada'
|
| is any thing like substring() function ?

yes. FIND, POSITION, SEARCH, CHAR, SUBSEQ, etc.

note that most operations on characters and strings in Common Lisp are
simply special cases of operations on elements and sequences. many
C-based programmers are frustrated because they think that Common Lisp
has few string-handling functions. Common Lisp has few string-only
functions, so remember to look for sequence and array functions, too.

#:Erik

Erann Gat

읽지 않음,
2000. 2. 22. 오전 3:00:0000. 2. 22.
받는사람

As long as we're on the subject, what is the best way to iterate over
a string/sequence? (map nil ... s)? (dotimes (i (length s)) ...
(char s i) ...)?

E.

새 메시지 0개