Jump to content

Longest increasing subsequence: Difference between revisions

m (→‎{{header|PicoLisp}}: add comment)
Line 1,126:
 
=={{header|PicoLisp}}==
Adapted patience sorting approach:
<lang PicoLisp>(de longinc (Lst)
(let (D NIL R NIL)
Line 1,140:
(push 'R I) ) ) )
(flip R) ) )</lang>
 
Original recursive glutton:
<lang PicoLisp>(de glutton (L)
(let N (pop 'L)
(maxi length
(recur (N L)
(ifn L
(list (list N))
(mapcan
'((R)
(if (> (car R) N)
(list (cons N R) R)
(list (list N) R) ) )
(recurse (car L) (cdr L)) ) ) ) ) ) )
(test (2 4 5)
(glutton (3 2 6 4 5 1)))
(test (2 6 9 11 15)
(glutton (8 4 12 2 10 6 14 1 9 5 13 3 11 7 15)))
(test (-31 0 83 782)
(glutton (4 65 2 -31 0 99 83 782 1)) )</lang>
 
=={{header|Prolog}}==
298

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.