Jump to content

Mind boggling card trick: Difference between revisions

→‎{{header|Javascript}}: (Slight simplification of threeStacks function by currying)
m (→‎{{header|REXX}}: fixed code to not shuffle the same card.)
(→‎{{header|Javascript}}: (Slight simplification of threeStacks function by currying))
Line 374:
// threeStacks :: [Chars] -> ([Chars], [Chars], [Chars])
const threeStacks = cards => {
const go = ([rs, bs, ds],) => xs) => {
const lng = xs.length;
return 0 < lng ? (
1 < lng ? (() => {
const
rest[x, y] = droptake(2, xs),
[x, y]ds_ = takecons(2x, xsds);
return 'R' === x ? (
go([cons(y,'R' rs),=== bs, cons(x, ds)],? rest)(
) : go([rs, cons(y, bsrs), cons(xbs, ds)ds_], rest)
})( ) : go([rs, bs, cons(xy, dsbs), ds_])
)(drop(2, xs))
})() : [rs, bs, ds_]
) : [rs, bs, ds];
};
Line 391 ⟶ 393:
[],
[]
], )(cards);
};
 
9,659

edits

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