Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Life sucks, but death doesn't put out at all...." -- Thomas J. Kopp


devel / comp.lang.lisp / .Re: Exercises, chap. 3, Graham

SubjectAuthor
o .Re: Exercises, chap. 3, GrahamRobert L.

1
.Re: Exercises, chap. 3, Graham

<sv86in$10ov$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!1+1kAUxU95ucmQjGCrlLYA.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: .Re: Exercises, chap. 3, Graham
Date: Thu, 24 Feb 2022 15:00:40 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sv86in$10ov$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="33567"; posting-host="1+1kAUxU95ucmQjGCrlLYA.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. - Thu, 24 Feb 2022 15:00 UTC

Alan Crowe wrote:

> On the other hand I am careful to locate the style in a
> mythical past. There is an unhappy history of the
> style being taught as the one true way to program in Lisp,
> even though it is a rather clumsy style for day
> to day programming. For example, all my routines get reduced
> to one liners by using CL's built-in functions.
>
> (defun trad-count-CL (symbol start list)
> (declare (ignore start))
> (cons symbol (count symbol list)))
>
> (defun find-types-CL(tokens types)
> (declare (ignore types))
> (remove-duplicates tokens))
>
> (defun multi-count-CL (types tokens)
> (loop for x in types collect (trad-count-CL x 0 tokens)))
>
> (defun occurrences-CL (list)
> (sort (multi-count-CL (find-types-CL list '())
> list)
> #'> :key #'cdr))
>
> leading to
>
> (defun occurrences-CL-condensed (list)
> (sort (loop for x in (remove-duplicates list)
> collect (cons x (count x list)))
> #'> :key #'cdr))

Gauche Scheme:

"We don't need no stinkin' loops!"

(define (group-them stuff)
(if (null? stuff)
'()
(receive (these those) (partition (cut eqv? <> (car stuff)) stuff)
(cons these (group-them those)))))

(define (occurrences stuff)
(define groups (group-them stuff))
(values
(sort (map (lambda (xs) (cons (car xs) (length xs))) groups) > cdr)
groups))

(occurrences '(b a d c d c b d c d))
===>
((d . 4) (c . 3) (b . 2) (a . 1))
((b b) (a) (d d d d) (c c c))


devel / comp.lang.lisp / .Re: Exercises, chap. 3, Graham

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor