Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Advice for a new lisper

23 views
Skip to first unread message

Robert L.

unread,
May 17, 2018, 9:05:19 PM5/17/18
to
Kenny Tilton wrote:

> > (defun straightp (hand)
> > (if (null (cdr hand))
> > t
> > (and (= (caar hand) (- (caadr hand) 1)) (straightp (cdr hand)))))
>
> Not bad, except of course for the caar/caadr thing. Lisniks have an
> irrational bias against recursion where iteration will do, so if they
> turn on you just come back with:
>
> (loop for (c1 c2) on hand
> unless c2 return t
> unless <in order> return nil)

(require srfi/1) ; map (handles lists of different lengths)

(define (straight? hand)
(define ranks (map car hand))
(equal? '(1 1 1 1)
(map - (cdr ranks) ranks)))

> (straight? '((2 H) (3 C) (4 S) (5 D) (6 H)))
#t
> (straight? '((2 H) (3 C) (4 S) (5 D) (9 H)))
#f

--
Mr. Porter disclosed the fact that his ... staff in the Embassy ... had ...
decoded communications between the commander ... and the Israeli High Command,
which proved that the latter knew that the Liberty was an unarmed American
naval vessel, and ... ordered that the American ship be attacked and sunk.
http://archive.org/details/nolies
0 new messages