This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ImpureDatabaseWrapper { | |
private $sql; | |
private $pureBinding; | |
/** | |
* @var \Zend_Db_Select $sql | |
* @var \Closure $pureBinding (Closure that contains "pure" code - i.e. it doesn't cause any side-effects!) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- The following holds true permuteAll [ [ 'a','b' ], [ 'c','d' ] ] => [ ['a','c'],['a','d'], ['b','c'], ['b','d'] ] | |
permuteAll :: [[a]] -> [[a]] | |
permuteAll [] = [] | |
permuteAll (x:[]) = splitEvery 1 x | |
permuteAll (x:xs) = foldr (++) [] $ map f x | |
where | |
f :: a -> [[a]] | |
f x' = map ( \y -> (x':y) ) (permuteAll xs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- such that the following holds true (where => indicates function output) | |
-- splicer [ ['a', 'b'], ['c', 'd'], ['e', 'f'] ] => [ ['a', 'c', 'e'], ['b', 'd', 'f'] ] | |
splicer :: [[a]] -> [[a]] | |
splicer [] = [] | |
splicer (x:[]) = splitEvery 1 x | |
splicer (x:xs) = zipWith (:) x $ splicer xs |
NewerOlder