Fractran: Difference between revisions

m
→‎JS Functional: Pruned some more unused functions
(→‎JS Functional: Pruned out a few unused functions)
m (→‎JS Functional: Pruned some more unused functions)
Line 2,043:
length: 2
});
 
// | Absolute value.
 
// abs :: Num -> Num
Line 2,052 ⟶ 2,050:
const bindMay = (mb, mf) =>
mb.Nothing ? mb : mf(mb.Just);
// concatMap :: (a -> [b]) -> [a] -> [b]
const concatMap = (f, xs) =>
xs.reduce((a, x) => a.concat(f(x)), []);
 
// div :: Int -> Int -> Int
Line 2,078 ⟶ 2,072:
return Nothing();
};
 
// findIndices :: (a -> Bool) -> [a] -> [Int]
// findIndices :: (String -> Bool) -> String -> [Int]
const findIndices = (p, xs) =>
concatMap((x, i) => p(x, i, xs) ? (
[i]
) : [], xs);
 
// fmapMay (<$>) :: (a -> b) -> Maybe a -> Maybe b
Line 2,102 ⟶ 2,089:
return _gcd(abs(x), abs(y));
};
 
// isChar :: a -> Bool
const isChar = x =>
('string' === typeof x) && (1 === x.length);
 
// iterate :: (a -> a) -> a -> Gen [a]
9,659

edits