Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You will have a long and boring life.


comp / comp.lang.lisp / Re: Use of format or pprint

SubjectAuthor
o Re: Use of format or pprintB. Pym

1
Subject: Re: Use of format or pprint
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 2 Jul 2024 18:44 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: Use of format or pprint
Date: Tue, 2 Jul 2024 18:44:00 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <v61hpf$1ogjd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Tue, 02 Jul 2024 20:44:01 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f8299da78adc737e104c9a85fb07d21d";
logging-data="1852013"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hKp5h5PXzn3t6kw7N+d2z"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:IKWvYxPhb9jZIUvTeKA/CQIm0E0=
View all headers

> Here are some functions I've written to convert strings into
> lists of various sorts. Examples follow at the end.
>
> (defun list-from-string (string
> &key
> (start 0)
> (char-bag '(#\Space))
> (test #'(lambda (ch)
> (not (member ch char-bag
> :test 'char=))))
> (post-process 'identity))
> (let ((pos (position-if test string :start start)))
> (if pos
> (list-from-string* string :start pos :char-bag char-bag
> :test test :post-process post-process)
> nil)))
>
> (defun list-from-string* (string
> &key
> (start 0)
> (char-bag '(#\Space))
> (test #'(lambda (ch)
> (not (member ch char-bag :test 'char=))))
> (post-process 'identity))
> (let* ((pos (position-if-not test string :start start))
> (new-pos (if pos (position-if test string :start pos) nil)))
> (cond
> ((and pos new-pos)
> (cons (funcall post-process (subseq string start pos))
> (list-from-string* string :start new-pos :char-bag char-bag
> :test test :post-process post-process)))
> (pos (list (funcall post-process (subseq string start pos))))
>
> (t (list (funcall post-process (subseq string start)))))))
....
> (list-from-string "chris! dan! ski! elaine! nick!"
> :char-bag '(#\Space #\!)) -->
> ("chris" "dan" "ski" "elaine" "nick")

Gauche Scheme

(use srfi-13)
(use srfi-14)

(string-tokenize
" chris!..?..!dan!ski!;elaine! nick! "
char-set:letter)

===>
("chris" "dan" "ski" "elaine" "nick")

1

rocksolid light 0.9.8
clearnet tor