Dutch national flag problem: Difference between revisions
Content added Content deleted
(gp) |
|||
Line 354: | Line 354: | ||
Anyways, we can test that they are indeed sorted properly: |
Anyways, we can test that they are indeed sorted properly: |
||
<lang J> assert@(-: /:~)&b2i /:~&.b2i BALLS</lang> |
<lang J> assert@(-: /:~)&b2i /:~&.b2i BALLS</lang> |
||
=={{header|Mathematica}}== |
|||
<lang Mathematica>flagSort[data_List] := Sort[data, If[#1 === RED || #2 === BLUE, True, False] &]</lang> |
|||
{{out}} |
|||
<pre>flagSort[{WHITE, RED, RED, WHITE, WHITE, BLUE, WHITE, BLUE, BLUE, WHITE, WHITE, BLUE}] |
|||
{RED, RED, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, BLUE, BLUE, BLUE, BLUE}</pre> |
|||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |