forked from colonelpanic/dotfiles
Add knightDeltas.hs
This commit is contained in:
parent
db2ad6f48d
commit
af1b2b877b
22
dotfiles/lib/bin/knightDeltas.hs
Executable file
22
dotfiles/lib/bin/knightDeltas.hs
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env run_haskell_stack.sh
|
||||||
|
|
||||||
|
import Data.Bifunctor
|
||||||
|
import Data.Tuple
|
||||||
|
|
||||||
|
knightDeltasSimple =
|
||||||
|
applyAll [swap] (1, 2)
|
||||||
|
>>= applyAll [first negate, second negate, bimapBoth negate]
|
||||||
|
where applyAll fns v = map ($ v) $ id:fns
|
||||||
|
bimapBoth fn = bimap fn fn
|
||||||
|
|
||||||
|
knightDeltas = applyInStages [(1, 2)]
|
||||||
|
[ [swap]
|
||||||
|
, [bimapBoth (* 2)]
|
||||||
|
, [first negate, second negate, bimapBoth negate]
|
||||||
|
]
|
||||||
|
where applyAll fns v = map ($ v) $ id:fns
|
||||||
|
applyAllToValues values fns = values >>= applyAll fns
|
||||||
|
applyInStages = foldl applyAllToValues
|
||||||
|
bimapBoth fn = bimap fn fn
|
||||||
|
|
||||||
|
main = print knightDeltas
|
Loading…
Reference in New Issue
Block a user