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 http://lpaste.net/4698665561507233792
  • 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 http://lpaste.net/2137455526429065216 Ah! Of course! 3,000 circles (unscaled, with numeric indices) look like a mess! Of course! http://lpaste.net/7343132373682225152 
  • August 28th, 2015: For today's #haskell problem: you said you wuz #BigData but you wuz only playin'! http://lpaste.net/5582316999184220160 View and scale 'some' data today. Playahz gunna play ... with ... wait: lenses? WAT? http://lpaste.net/3840444612304961536
  • August 27th, 2015: Today's #haskell problem inspired from twitter: prove the soundness of ME + YOU = FOREVER http://lpaste.net/324064108640993280 Today's #haskell solution is a simpl(istic)e and specific arithmetic (dis)prover http://lpaste.net/181333197114572800 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 http://lpaste.net/8121218308407033856 Bright eyes! burnin' like fire! http://lpaste.net/6043805058976448512 
  • August 25th, 2015: Well, color me surprised! Today's #haskell problem asks to color by Num(bers) http://lpaste.net/3178349384714682368 And we find out how colors can be numbers, or numbers (Integers) can be colors ... either way http://lpaste.net/2477807113129164800
  • August 24th, 2015: You thought I would say 'Purple' (as in Rain) for today's #haskell problem, but I was only playin' http://lpaste.net/1249981301570666496 #PSA Circles are NOT jerkles ... because ... I don't even know what 'jerkles' ARE! http://lpaste.net/9210044109090193408
  • August 21st, 2015: So, ooh! PRITTY COLOURS YESTERDAY! BUT WHAT DO THEY MEAN? Today's #haskell problem we cluster data http://lpaste.net/4331594901654339584 DO IT TO IT!
  • August 20th, 2015: For today's #haskell problem, now that we have yesterday solved, let's COLOUR the dots! http://lpaste.net/6809671420902113280 Okay, very hack-y but, indeed: colour-y! http://lpaste.net/6080330641977638912 (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 http://lpaste.net/1002579649038909440 Share you results here on twitter! Ooh! I see blue dots! K3wl! http://lpaste.net/8209124658184716288 
  • 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 http://lpaste.net/4873818871913512960 Today, the SCA/Society for Creative Anachronisms solved the problem. No: SCA/Score Card Analysis ... my bad! http://lpaste.net/4574974476227182592
  • 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! http://lpaste.net/4021501857770766336 We learn that @geophf cannot come up with interesting title names for lpaste.net so early in the morning! http://lpaste.net/2865245555871711232
  • August 14th, 2015: We find out in today's #haskell problem that if 'kinda-prime' numbers had a taste, they would be 'yummy.' http://lpaste.net/8115330625503756288
  • August 13th, 2015: We generalize to divbyx-rule by using Singapore Maths-laaaaah http://lpaste.net/7999541914976124928 for today's #Haskell problem "divby7 is too easy now-laaaah!" http://lpaste.net/3424362847981797376 ... 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 http://lpaste.net/4853502121825271808 "There, fixed divby3 for ya!" you crow, in on the 'fix'-joke http://lpaste.net/1103072314578173952 *groan *fixpoint-humour
  • August 11th, 2015: Today, I ask you to step up your composable-game, #haskell-tweeps! http://lpaste.net/793067287459397632 Today's div-by #haskell problem So we ♫ 'head for the mountains!' ♫ for our composable solution of divby10 and divby30 http://lpaste.net/7676519782581010432 but leave an open question ...
  • August 10th, 2015: Neat little paper on divisibility rules (http://www.cicm-conference.org/2015/fm4m/FMM_2015_paper_6.pdf) leads to today's #Haskell problem http://lpaste.net/5543352342910337024: divide by 3 rule! A number is divisible by three if the sum of its digits are. PROVED! http://lpaste.net/3154300080412950528
  • August 7th, 2015: For today's #haskell problem we relook yesterday's with Data.Monoid and fold(r) ... for fun(r) http://lpaste.net/7556489465431064576 We're using code from the future (or the bonus answer, anyway) to answer today's #haskell problem http://lpaste.net/1417188853759868928
  • August 6th, 2015: For today's #haskell problem, @elizabethfoss provides us the opportunity to do ... MATHS! http://lpaste.net/4497234580327104512 TALLY HO! Today's solution has Haskell talking with a LISP! (geddit? ;) http://lpaste.net/8042173730291449856
  • August 5th, 2015: Today's #Haskell problem shows us that 'anagramatic' is a word now, by way of @argumatronic http://lpaste.net/7378835938597666816 We learned that #thuglife and #GANGSTA are a bifunctor, but not anagrams with http://lpaste.net/4458286223454109696 @argumatronic 
  • August 4th, 2015: We actually write a PROGRAM for today's #haskell problem that DOES STUFF! WOW! http://lpaste.net/7617945186101886976 #curbmyenthusiasm #no Today we learnt to talk like a pirate ... BACKWARDS! http://lpaste.net/1920179878318047232 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 http://lpaste.net/3336770284219793408 ;)