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

re: Advice for a new lisper

77 views
Skip to first unread message

WJ

unread,
May 26, 2012, 11:22:17 AM5/26/12
to
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
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)

Racket:

(define (straight? hand)
(define (delta1 a b) (= 1 (- (car a) (car b))))
(andmap delta1 (take hand 4) (drop hand 1)))

(straight? '((9 h)(8 d)(7 c)(6 s)(5 h)))
=> #t

WJ

unread,
Oct 17, 2012, 11:33:39 PM10/17/12
to
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
(define (straight? hand [ranks (map first hand)])
(equal? (map - (take ranks 4) (drop ranks 1)) '(1 1 1 1)))

WJ

unread,
Jan 6, 2015, 12:33:11 AM1/6/15
to
WJ wrote:

> 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)


Gauche Scheme:

(define (straight? hand)
(every in-order? hand (cdr hand)))

WJ

unread,
Jul 24, 2016, 7:43:28 PM7/24/16
to
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
OCaml:

open List ;;

let is_straight hand =
for_all2 in_order (rev (tl (rev hand))) (tl hand) ;;

--
[A]daptive behavior and group-identifications of gentiles were pathologized
while Jewish group identification, ingroup pride, family pride, upward social
mobility, and group continuity retained their psychological importance and
positive moral evaluation. --- Kevin MacDonald; "The Frankfurt School of Social
Research and the Pathologization of Gentile Group Allegiances"
0 new messages