Non-continuous subsequences: Difference between revisions
Content added Content deleted
m (Added the Sidef language) |
(→{{header|Perl 6}}: modernize) |
||
Line 1,393: | Line 1,393: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{works with|rakudo|2015-09-24}} |
|||
Uses powerset() function from [[Power Set#Perl_6|here]]. |
|||
<lang perl6>sub non_continuous_subsequences ( *@list ) { |
<lang perl6>sub non_continuous_subsequences ( *@list ) { |
||
@list.combinations.grep: { 1 != all( .[ 0 ^.. .end] Z- .[0 ..^ .end] ) } |
|||
} |
} |
||
⚫ | |||
sub powerset ( *@list ) { |
|||
⚫ | |||
reduce( -> @L, $n { [ @L, @L.map: {[ .list, $n ]} ] }, [[]], @list ); |
|||
⚫ | |||
} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
{{out}} |
{{out}} |
||
<pre> |
<pre>((1 3)) |
||
((1 3) (1 4) (2 4) (1 2 4) (1 3 4)) |
|||
[ |
([a c] [a d] [b d] [a b d] [a c d])</pre> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |