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