Thursday, September 3, 2015

1Liners August 2015

  • August 20th, 2015: Okay this: \(a,b) -> foo a b c d e Somehow curry-i-tize the above expression (make a and b go away!) Is this Applicative?
    • JP @japesinator uncurry $ flip flip e . flip flip d . flip flip c . foo
    • Conor McBride @pigworker (|foo fst snd (|c|) (|d|) (|e|)|)
  • August 19th, 2015: points-free define unintify: unintify :: (Int, Int) -> (Float, Float) where unintify (a,b) = (fromIntegral a, fromIntegral b)
  • August 19th, 2015: points-free define timeser: timeser :: (Float, Float) -> (Float, Float) -> (Float, Float) where timeser (a,b) (c,d) = (a*c, b*d)
  • August 18th, 2015: foo :: (Float, Float) -> (Float, Float) -> Int -> (Float, Float) points-free if: foo (a,b) (c,d) e = ((c-a)/e, (d-b)/e) Arrows? Bimaps?

1Liners July 2015

  • July 29th, 2015: ... on a roll: Point-free-itize
    foo :: (a -> b, a -> b) -> (a, a) -> (b, b)
    foo (f,g) (x,y) = (f x, g y)
    • \[ c^3 \] @das_kube uncurry (***)
  • July 29th, 2015: I can't believe this wasn't a #1Liner already. Point-free-itize dup:
    dup :: a -> (a,a)
    dup x = (x,x)
    • Antonio Nikishaev @lelff join (,)
    • \[ c^3 \] @das_kube id &&& id
  • July 23rd, 2015: define pairsies so that, e.g.: pairsies [1,2,3] = {{1, 2}, {1, 3}, {2, 3}} pairsies :: [a] -> Set (Set a)
    • pairsies list = concat (list =>> (head &&& tail >>> sequence))
  • July 23rd, 2015: define both :: (a -> b) -> (a,a) -> (b,b)
    • Chris Copeland @chrisncopeland point-freer: both = uncurry . on (,)
    • Brian McKenna @puffnfresh both = join bimap
  • July 23rd, 2015: point-free-itize: gen :: Monad m => (m a, m b) -> m (a, b)
    • Bob Ippolito @etrepum gen = uncurry (liftM2 (,))
  • July 17th, 2015: You may have seen this before, but here we go. point-free-itize swap:
    swap :: (a,b) -> (b,a)

1Liners Pre-July 2015

  • Point-free define: foo :: (Ord a, Ord b) => [([a], [b])] -> (Set a, Set b)
    • Андреев Кирилл @nonaem00 foo = (Set.fromList . concat *** Set.fromList . concat) . unzip
  • point-free-itize computeTotalWithTax :: Num b => ((a, b), b) -> b computeTotalWithTax ((a, b), c) = b + c
  • point-free-itize foo (k,v) m = Map.insert k b m with obvs types for k, v, and m.
  • point-free-itize: shower :: forall a. forall b. Show a => [b -> a] -> b -> [a] shower fns thing = map (app . flip (,) thing) fns
  • row :: String -> (Item, (USD, Measure)) given csv :: String -> [String] and line is = "apple,$1.99 Lb" hint: words "a b" = ["a","b"] ... all types mentioned above are in today's @1HaskellADay problem at
  • For Read a, point-free-itize: f a list = read a:list (f is used in a foldr-expression)
    • Or you could just do: map read
  • point-free-itize f such that: f a b c = a + b + c

Tuesday, September 1, 2015

August 2015 1HaskellADay Problems and Solutions

August 2015

  • August 31st, 2015: What do 3,000 circles look like? We answer this question in today's #haskell problem Ah! Of course! 3,000 circles (unscaled, with numeric indices) look like a mess! Of course! 
  • August 28th, 2015: For today's #haskell problem: you said you wuz #BigData but you wuz only playin'! View and scale 'some' data today. Playahz gunna play ... with ... wait: lenses? WAT?
  • August 27th, 2015: Today's #haskell problem inspired from twitter: prove the soundness of ME + YOU = FOREVER Today's #haskell solution is a simpl(istic)e and specific arithmetic (dis)prover ME+YOU /= FOREVER It ain't happenin'
  • August 26th, 2015: You've heard of The Darkness? Well, today's #haskell problem is all about the Brightness Bright eyes! burnin' like fire! 
  • August 25th, 2015: Well, color me surprised! Today's #haskell problem asks to color by Num(bers) And we find out how colors can be numbers, or numbers (Integers) can be colors ... either way
  • August 24th, 2015: You thought I would say 'Purple' (as in Rain) for today's #haskell problem, but I was only playin' #PSA Circles are NOT jerkles ... because ... I don't even know what 'jerkles' ARE!
  • August 21st, 2015: So, ooh! PRITTY COLOURS YESTERDAY! BUT WHAT DO THEY MEAN? Today's #haskell problem we cluster data DO IT TO IT!
  • August 20th, 2015: For today's #haskell problem, now that we have yesterday solved, let's COLOUR the dots! Okay, very hack-y but, indeed: colour-y! (and the index colours need work, too ...)
  • August 19th, 2015: Let's look at some cells in a bounding box, shall we? for today's #haskell problem Share you results here on twitter! Ooh! I see blue dots! K3wl! 
  • August 18th, 2015: In #hadoop you can store a lot of data...but then you have to interpret that stored data for today's #haskell program Today, the SCA/Society for Creative Anachronisms solved the problem. No: SCA/Score Card Analysis ... my bad!
  • August 17th, 2015: For Today's #haskell problem we learn that bb does NOT mean 'Big Brother' (1984). What DOES it mean, then? Tune in! We learn that @geophf cannot come up with interesting title names for so early in the morning!
  • August 14th, 2015: We find out in today's #haskell problem that if 'kinda-prime' numbers had a taste, they would be 'yummy.'
  • August 13th, 2015: We generalize to divbyx-rule by using Singapore Maths-laaaaah for today's #Haskell problem "divby7 is too easy now-laaaah!" ... but there are interesting results for tomorrow's problem
  • August 12th, 2015: Is divby3 a fixpoint? We address this question in today's #haskell problem "There, fixed divby3 for ya!" you crow, in on the 'fix'-joke *groan *fixpoint-humour
  • August 11th, 2015: Today, I ask you to step up your composable-game, #haskell-tweeps! Today's div-by #haskell problem So we ♫ 'head for the mountains!' ♫ for our composable solution of divby10 and divby30 but leave an open question ...
  • August 10th, 2015: Neat little paper on divisibility rules ( leads to today's #Haskell problem divide by 3 rule! A number is divisible by three if the sum of its digits are. PROVED!
  • August 7th, 2015: For today's #haskell problem we relook yesterday's with Data.Monoid and fold(r) ... for fun(r) We're using code from the future (or the bonus answer, anyway) to answer today's #haskell problem
  • August 6th, 2015: For today's #haskell problem, @elizabethfoss provides us the opportunity to do ... MATHS! TALLY HO! Today's solution has Haskell talking with a LISP! (geddit? ;)
  • August 5th, 2015: Today's #Haskell problem shows us that 'anagramatic' is a word now, by way of @argumatronic We learned that #thuglife and #GANGSTA are a bifunctor, but not anagrams with @argumatronic 
  • August 4th, 2015: We actually write a PROGRAM for today's #haskell problem that DOES STUFF! WOW! #curbmyenthusiasm #no Today we learnt to talk like a pirate ... BACKWARDS! ARGGGH! ... no ... wait: !HGGGRA Yeah, that's it.
  • August 3rd, 2015: For today's #haskell problem, we design a Hadoop database ... ya know, without all that bothersome MapReduce stuff ;)