Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Hailstone-sequence/TXR/hailstone-sequence.txr
Normal file
26
Task/Hailstone-sequence/TXR/hailstone-sequence.txr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
@(do (defun hailstone (n)
|
||||
(cons n
|
||||
(gen (not (eq n 1))
|
||||
(set n (if (evenp n)
|
||||
(trunc n 2)
|
||||
(+ (* 3 n) 1)))))))
|
||||
@(next :list @(mapcar* (fun tostring) (hailstone 27)))
|
||||
27
|
||||
82
|
||||
41
|
||||
124
|
||||
@(skip)
|
||||
8
|
||||
4
|
||||
2
|
||||
1
|
||||
@(eof)
|
||||
@(do (let ((max 0) maxi)
|
||||
(each* ((i (range 1 99999))
|
||||
(h (mapcar* (fun hailstone) i))
|
||||
(len (mapcar* (fun length) h)))
|
||||
(if (> len max)
|
||||
(progn
|
||||
(set max len)
|
||||
(set maxi i))))
|
||||
(format t "longest sequence is ~a for n = ~a\n" max maxi)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue