Longest increasing subsequence: Difference between revisions

Corrected typo in the language name. Updated to compile with Nim 1.4. Other minor changes.
(Add Maple solution)
(Corrected typo in the language name. Updated to compile with Nim 1.4. Other minor changes.)
Line 1,450:
<pre>{{2,4,5},{0,2,6,9,11,15}}</pre>
 
=={{header|NirodNim}}==
{{trans|Python}}
<lang nimrodNim>proc longestIncreasingSubsequence[T](d: seq[T]): seq[T] =
var l: = newSeqseq[seq[T]]()
for i in 0 .. <d.lenhigh:
var x: = newSeqseq[T]()
for j in 0 .. < i:
if l[j][l[j].high] < d[i] and l[j].len > x.len:
x = l[j]
l.add x & @[d[i]]
result = @[]
for x in l:
if x.len > result.len:
Line 1,466 ⟶ 1,465:
 
for d in [@[3,2,6,4,5,1], @[0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15]]:
echo "aA L.I.S. of ", d, " is ", longestIncreasingSubsequence(d)</lang>
{{out}}
<pre>aA L.I.S. of @[3, 2, 6, 4, 5, 1] is @[3, 4, 5]
aA L.I.S. of @[0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15] is @[0, 4, 6, 9, 13, 15]</pre>
 
=={{header|Objective-C}}==
Anonymous user