[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: Help with small prog please

William James

5/13/2015 1:46:00 PM

Steve Gonedes wrote:

> < Also :-
> < (defun wall (n)
> < (cond ((= n 0) nil (oddp n))
> <
> < (t (cons 'brick (wall (- n 1)))))))
> <
> < (wall 7)
>
> (defun wall (brick-count)
> (cond ((zerop brick-count) (list 'brick))
> (t (cons 'brick
> (cons 'mortar
> (wall (- brick-count 1)))))))
>
> (wall 3) => (brick mortar brick mortar brick mortar brick) ?

Gauche Scheme:

(define (wall brick-count)
(intersperse 'mortar (make-list brick-count 'brick)))

gosh> (wall 3)
(brick mortar brick mortar brick)
gosh> (wall 1)
(brick)

--
In Norway, in 2011, 14-year-old Eva Helgetun was assaulted and gang-raped by
three teenage boys "of foreign origin," which is how the politically correct
papers in Sweden refer to Muslim rapists. Although she was able to escape her
attackers without any obvious physical injuries, Eva was so terribly damaged by
the assault, she committed suicide four weeks later.
http://www.liveleak.com/view?i=807_...
1 Answer

William James

12/1/2015 7:28:00 AM

0

WJ wrote:

> Steve Gonedes wrote:
>
> > < Also :-
> > < (defun wall (n)
> > < (cond ((= n 0) nil (oddp n))
> > <
> > < (t (cons 'brick (wall (- n 1)))))))
> > <
> > < (wall 7)
> >
> > (defun wall (brick-count)
> > (cond ((zerop brick-count) (list 'brick))
> > (t (cons 'brick
> > (cons 'mortar
> > (wall (- brick-count 1)))))))
> >
> > (wall 3) => (brick mortar brick mortar brick mortar brick) ?

Ocaml:

let rec wall = function
0 -> []
| 1 -> ["brick"]
| n -> ["brick"; "mortar"] @ wall (n - 1) ;;

# wall 0;;
- : string list = []
# wall 1;;
- : string list = ["brick"]
# wall 2;;
- : string list = ["brick"; "mortar"; "brick"]
# wall 3;;
- : string list = ["brick"; "mortar"; "brick"; "mortar"; "brick"]

--
Turkish teens gang-raped a 16-year-old girl ... and assaulted her with a
bottle. Even when the bottle broke, they continued her attack, eventually
severing her intestine and her uterus.... German privacy laws meant that the
attack went entirely unreported in the German press.
http://www.liveleak.com/view?i=807_...