[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: which articles are sold?

William James

6/5/2015 10:34:00 AM

Lieven Marchand wrote:

> > if we have this list:
> > (a <sold> b c d <sold> e f g <sold>)
> > that shows that article a, d and g are sold and the rest are not how
> > can we put all the sold articles in one list:
> > (a d g)
>
> More homework?
>
> (loop for (first next) on '(a <sold> b c d <sold> e f g <sold>)
> when (eql next '<sold>)
> collect first)

Gauche Scheme:

(define items '(a <sold> b c d <sold> e f g <sold>))

(filter-map
(^(x y) (and (eq? '<sold> y) x))
items
(cdr items))

===>
(a d g)

--
Viewed at its most abstract level, a fundamental agenda is thus to influence
the European-derived peoples of the United States to view concern about their
own demographic and cultural eclipse as irrational and as an indication of
psychopathology. --- Kevin MacDonald; "The Frankfurt School of Social Research
and the Pathologization of Gentile Group Allegiances"
1 Answer

William James

11/28/2015 4:49:00 PM

0

WJ wrote:

> Lieven Marchand wrote:
>
> > > if we have this list:
> > > (a <sold> b c d <sold> e f g <sold>)
> > > that shows that article a, d and g are sold and the rest are not how
> > > can we put all the sold articles in one list:
> > > (a d g)
> >
> > More homework?
> >
> > (loop for (first next) on '(a <sold> b c d <sold> e f g <sold>)
> > when (eql next '<sold>)
> > collect first)
>
> Gauche Scheme:
>
> (define items '(a <sold> b c d <sold> e f g <sold>))
>
> (filter-map
> (^(x y) (and (eq? '<sold> y) x))
> items
> (cdr items))
>
> ===>
> (a d g)

Ocaml:

["a";"<sold>";"b";"c";"d";"<sold>";"e";"f";"g";"<sold>"] |>
(let rec loop = function
item::"<sold>"::more -> item :: loop more
| x::xs -> loop xs
| [] -> []
in loop);;

===>
["a"; "d"; "g"]

--
[W]e had enough employees who made more than 85 to fill all the openings. The
highest score that any of the blacks scored on the test was 11. The lowest
score that any black made on the test was 4. All four of those blacks went
into skilled-trades training.
https://archive.org/download/TheOldmanArchives/oldman29-...