- September 18th, 2015:
Okay so we know the tuple2list function doesn't exist generally, but ...
t2l :: (a,a) -> [a]
define t2l points-free - JP @japesinator uncurry ((. pure) . (:))
- 熊井さん @lotz84_ reverse . uncurry ((flip (:)) . (:[]))
- bazzargh @bazzargh ap[fst,snd].(:[])
- September 17th, 2015:
(bifunctor crowd is rubbing their hands here...)
you have x,y :: [(a, b)]
you need p,q :: [b]
define fi such that fi (x,y) ~> (p,q) - obadz @obadzz fi = bimap f f where f = map snd ?
- [revised:] fi = join bimap f where f = map snd
- September 17th, 2015:
dist :: (Num a, Floating a) => [a] -> [a] -> a
dist is the sqrt of the sum of the squared-diffs
define the curried fn: dist vs - September 11th, 2015: You have this: doubleplus = join (***) (+) define f point-free: f :: Num a => (a, a) -> (a, a) -> (a, a) f (a,b) (c, d) = (a+c, b+d)
- obadz @obadzz (<<*>>) . (<<*>>) ((+), (+))
- Greg Manning @ghyu f = uncurry bimap . doubleplus
- September 8th, 2015: Given f :: a -> b -> c define g :: [(a, [b])] -> [c] points-free
- Freddy Román @frcepeda g = concatMap (uncurry (map . f))
- Gautier DI FOLCO @gautier_difolco
concatMap (uncurry (zipWith ($)) . bimap (map f . repeat) id) - Daniel Gazard @danielgazard g = map (uncurry f) . concatMap (uncurry ((<$>) . (,)))
- September 8th, 2015: Given f :: Monoid b => [a] -> b
define b :: [a] -> (b, [b]) -> (b, [b]) points-free
such that
b c (x, r) = (x `mappend` f c, f c:r) - Chris Copeland @nopasetic b = uncurry bimap . bimap ((<>) . f) ((:) . f) . join (,)
- Gautier DI FOLCO @gautier_difolco uncurry bimap . bimap (<>) (:) . join (,) . f
- September 8th, 2015: Given data X a b c = X a b c
and f :: a -> b
define foo :: a -> c -> X a b c
points-free - failingattempt @failingattempt foo = X <*> f
- September 4th, 2015: summer :: (a, Float) -> (a, Float) -> (a, Float)
summer (x, a) (_, b) = (x, a + b)
define summer, points-free - Stijn van Drongelen @rhymoid fmap . (+) . snd
- September 3rd, 2015: suggested by @BeRewt: f :: [a -> b] -> a -> [b] define f points-free
- \[ c^3 \] @das_kube sequence
- Matthew Avant @mavant flip $ (<**>) . pure
- September 3rd, 2015: What is it with y'all's #1Liner-speed-of-response? (I'm lovin' it, actually) sq :: Num a => a -> a sq x = x * x define sq points-free
- Nicoλas @BeRewt join (*)
- \[ c^3 \] @das_kube uncurry (*) . (id &&& id) (yes, ugly)
- September 3rd, 2015: snds :: (a,b) -> (a,b) -> (b,b) define snds, points-free
- September 3rd, 2015: tuple :: a -> b -> (a, b) define tuple, points-free
- Nicoλas @BeRewt (,)
- \[ c^3 \] @das_kube curry $ id *** id
- Olivier Iffrig @oiffrig tuple = (,) Alternatively, tuple = curry id
- September 3rd, 2015:
you have f :: a -> b -> c you want g :: (a -> b -> [c]) -> a -> b -> d convert f to function that is accepted by g - obadz @obadzz ((:[]) .) . f
- Nicoλas @BeRewt I prefer 'return' to '(:[])'
- Matthew Avant @mavant ((.).(.)) (:[]) f, I suppose
- September 1st, 2015: You have Functor-instance R a, declared R (a,a,a) You have f :: a -> a -> a define mappend :: R a -> R a -> R a, using f once only
- obadz @obadzz unless you've got an applicative instance then mappend = liftA2 f
Incorporates strong typing over predicate logic programming, and, conversely, incorporates predicate logic programming into strongly typed functional languages. The style of predicate logic is from Prolog; the strongly typed functional language is Haskell.
Wednesday, October 14, 2015
September 2015 1HaskellADay 1Liners
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment