Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

One man's constant is another man's variable. -- A. J. Perlis


devel / comp.lang.lisp / Re: .Re: cl-ppcre question

SubjectAuthor
* .Re: cl-ppcre questionRobert L.
`- Re: .Re: cl-ppcre questionZyni Moë

1
.Re: cl-ppcre question

<sv5i5c$n2j$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16919&group=comp.lang.lisp#16919

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!ncXrTuJX+h8WepL7m+lpwA.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: .Re: cl-ppcre question
Date: Wed, 23 Feb 2022 14:59:57 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sv5i5c$n2j$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="23635"; posting-host="ncXrTuJX+h8WepL7m+lpwA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Wed, 23 Feb 2022 14:59 UTC

Madhu wrote:

> * Tamas Papp <87hcnwaky1.fsf@pu100877.student.princeton.edu> :
>
> | Hi,
> |
> | I would like to parse color names in X11's rgb.txt. They look like this:
> |
> | 119 136 153 light slate gray
> | 119 136 153 LightSlateGray
> |
> | When parsing each line, I would like to get the color triplet, and the
> | name. I tried it like this:
> |
> | (let ((color-scanner
> | (cl-ppcre:create-scanner
> | "^ +([0-9]{0,2}) +([0-9]{0,2}) +([0-9]{0,2}) +([ a-zA-Z0-9]+)")))
> | (cl-ppcre:scan-to-strings color-scanner " 1 2 3 foo bar baz "))
> |
> | This gives #("1" "2" "3" "foo bar baz ") for the substrings. How can
> | I get rid of the trailing spaces?
>
> Use the right tool for the job :)
>
> (defun parse-rgb-line (string &key (start 0) end)
> (multiple-value-bind (r endr)
> (parse-integer string :start start :end end :junk-allowed t)
> (multiple-value-bind (g endg)
> (parse-integer string :start (1+ endr) :end end :junk-allowed t)
> (multiple-value-bind (b endb)
> (parse-integer string :start (1+ endg) :end end :junk-allowed t)
> (let ((name-startpos
> (position-if-not (lambda (c) (case c ((#\Tab #\Space) t)))
> string :start (1+ endb))))
> (values (format nil "#~2,'0X~2,'0X~2,'0X" r g b)
> (subseq string name-startpos end)))))))
>

Testing under SBCL:

* (parse-rgb-line " 62 128 255 light blue ")

"#3E80FF"
"light blue "

Pure crap.

Gauche Scheme:

(use gauche.generator)

(define (parse-rgb-line line)
(define tokens
(with-input-from-string line (cut generator->list read)))
(list (take tokens 3)
(string-join (map symbol->string (drop tokens 3)) " ")))

(parse-rgb-line " 62 128 255 light blue ")
===>
((62 128 255) "light blue")

(parse-rgb-line "62 128 255 LightBlue")
===>
((62 128 255) "LightBlue")

Re: .Re: cl-ppcre question

<sv5lt2$f78$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16920&group=comp.lang.lisp#16920

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: .Re: cl-ppcre question
Date: Wed, 23 Feb 2022 16:03:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <sv5lt2$f78$1@dont-email.me>
References: <sv5i5c$n2j$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 23 Feb 2022 16:03:46 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="be3a6e4488bdf53569bdae7255a4b9b3";
logging-data="15592"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ecjRazrcCgdAZdZzfe1javfOdMLkMkNE="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:DKiYnotN448pt9JEmsPHFe3ll2c=
sha1:+aQ5oTefJR2aArfIe5QPw1DluL8=
 by: Zyni Moë - Wed, 23 Feb 2022 16:03 UTC

Robert L. <No_spamming@noWhere_7073.org> wrote:

> (define (parse-rgb-line line)
> (define tokens
> (with-input-from-string line (cut generator->list read)))
> (list (take tokens 3)
> (string-join (map symbol->string (drop tokens 3)) " ")))
>

He is using read. Because that is a good idea.
--
the small snake


devel / comp.lang.lisp / Re: .Re: cl-ppcre question

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor