Non-continuous subsequences: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Minor tidy) |
(added Easylang) |
||
Line 866: | Line 866: | ||
nc.writeln; |
nc.writeln; |
||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
=={{header|EasyLang}}== |
|||
{{trans|11l}} |
|||
<syntaxhighlight> |
|||
func[][] ncsub seq[] s . |
|||
if len seq[] = 0 |
|||
if s >= 3 |
|||
return [ [ ] ] |
|||
. |
|||
return [ ] |
|||
. |
|||
last = seq[$] |
|||
len seq[] -1 |
|||
p2 = s mod 2 |
|||
p1 = 1 - p2 |
|||
res[][] = ncsub seq[] (s + p2) |
|||
r[][] = ncsub seq[] (s + p1) |
|||
for i to len r[][] |
|||
r[i][] &= last |
|||
res[][] &= r[i][] |
|||
. |
|||
return res[][] |
|||
. |
|||
print ncsub [ 1 2 3 4 ] 0 |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
[ |
|||
[ 1 3 ] |
|||
[ 1 4 ] |
|||
[ 2 4 ] |
|||
[ 1 2 4 ] |
|||
[ 1 3 4 ] |
|||
] |
|||
</pre> |
|||
=={{header|Elixir}}== |
=={{header|Elixir}}== |