tag:blogger.com,1999:blog-46502940744445340662024-03-16T11:53:09.510-07:00Typed LogicIncorporates 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.geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.comBlogger215125tag:blogger.com,1999:blog-4650294074444534066.post-57971120564857516492021-11-09T14:57:00.008-08:002021-11-09T16:12:11.979-08:00November, 2021 1HaskellADay 1Liners<ul>
<li>2021-11-09: You have: <code>\k _v -> f k</code> Curry away the arguments.</li>
<li>2021-11-09: Hello, all. It's been a minute.
<p>Here's a #1Liner #Haskell problem
</p><p>You have m :: Map a b
</p><p>You want to filter it by s :: Set a
</p><p>so that m has keys only in s.
</p><p>How would you do that?
</p><ul>
<li>O_O @dysinger: let map = Data.Map.fromList [(1, "one"), (2, "two"), (3, "three")]<br />
set = Data.Set.fromList [1,3,5,7,9]<br />
in Data.Map.fromList [ elem | elem <- Data.Map.toList map, Data.Set.member (fst elem) set ]</li>
<li>ephemient @ephemient: Map.filterWithKey (\k _ -> Set.member k set) map
</li>
<li>ephemient @ephemient: Map.intersectionWith const map $ Map.fromDistinctAscList [(k, ()) | k <- Set.toAscList set]
</li>
<li>じょお @gotoki_no_joe Map.intersection m (Map.fromSet (const ()) s)
</li>
</ul></li>
</ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com2tag:blogger.com,1999:blog-4650294074444534066.post-9041036948150298312021-06-06T20:06:00.007-07:002021-06-06T21:03:23.556-07:00Why Kleisli Arrows Matter<p>We're going to take a departure from the style of articles regularly written about the Kleisli category, because, firstly, there aren't articles regularly written about the Kleisli category.</p><p>That's a loss for the world. Why? I find the Kleisli category so useful that I'm normally programming in the category, and, conversely, I find most code in industry, unaware of this category, is doing a lot of the work of (unintentionally) setting up this category, only to tear it down before using it effectively.</p><p>So. What is the Kleisli Category? Before we can properly talk about this category, and its applications, we need to talk about <a href="https://en.wikipedia.org/wiki/Monad_(category_theory)">monads</a>. </p><p><b>Monads</b></p><p>A monad, as you can see by following the above link, is a domain with some specific, useful properties. If we have a monad, <i>T,</i> we know it comes with an unit function, η, and a join function, μ. What do these 'thingies' do?</p><p></p><ul style="text-align: left;"><li><i>T</i>, the monadic domain, says that if you are the domain, then that's where you stay: <i>T</i>: <i>T </i><span face="Roboto, arial, sans-serif" style="background-color: white; color: #202124; font-size: 16px;">→</span><span face="Roboto, arial, sans-serif" style="background-color: white; color: #202124; font-size: 16px;"> </span><i>T.</i></li></ul><p></p><p>"So what?" you ask. The beauty of this is that once you've proved you're in a domain, then all computations from that point are guaranteed to be in that domain.</p><p>So, for example, if you have a monadic domain called <span style="font-family: courier;">Maybe</span>, then you know that values in this domain are <span style="font-family: courier;">Just</span> some defined value or <span style="font-family: courier;">Nothing</span>. What about <span style="font-family: courier;">null</span>? There is no <span style="font-family: courier;">null</span> in the <span style="font-family: courier;">Maybe</span>-domain, so you never have to prove your value is (or isn't) <span style="font-family: courier;">null</span>, once you're in that monadic domain.</p><p></p><ul style="text-align: left;"><li>But how do you prove you're in that domain? η lifts an unit value (or a 'plain old' value) from the ('plain old') domain into the monadic domain. You've just proved you're in the monadic domain, simply by applying η.</li></ul><p></p><p>η <span style="font-family: courier;">null</span> <span face="Roboto, arial, sans-serif" style="background-color: white; color: #202124; font-size: 16px;">→ </span>fails</p><p>η some value <span face="Roboto, arial, sans-serif" style="background-color: white; color: #202124; font-size: 16px;">→</span> some value in <i>T.</i></p><p></p><ul style="text-align: left;"><li>We're going to talk about the join-function, μ, after we define the Kleisli category.</li></ul><div><b>The Kleisli Category</b></div><p></p><p>Okay. Monads. Great. So what does have to do with the <a href="https://en.wikipedia.org/wiki/Kleisli_category">Kleisli category</a>? There's a problem with the above description of Monads that I didn't address. You can take any function, say:</p><p><i>f : A </i><span face="Roboto, arial, sans-serif" style="background-color: white; color: #202124; font-size: 16px;">→ </span><i>B</i></p><p>and lift that into the monadic domain:</p><p><i>f<sup>T</sup> : T A </i><span face="Roboto, arial, sans-serif" style="background-color: white; color: #202124; font-size: 16px;">→</span><i> T B</i></p><p>... but what is <i>f<sup>T</sup></i>? <i>f<sup>T </sup></i>looks exactly like <i>f, </i>when you apply elimination of the monadic domain, <i>T.</i> How can we prove or 'know' that anywhere in our computation we indeed end up in the monadic domain, so that the next step in the computation we know we are in that monadic domain, and we don't have to go all the way back to the beginning of the proof to verify this, every time?</p><p>Simple: that's what the Kleisli category does for us.</p><p>What does the Kleisli category do for us? Kleisli defines the Kleisli arrow thusly:</p><p><i>f<sup>K</sup> : A </i><span style="background-color: white; color: #202124; font-size: 16px;">→ </span><i>T B</i></p><p>That is to say, no matter where we start from in our (possibly interim) computation, we end our computation in the monadic domain. This is fantastic! Because now we no longer need to search back any farther than this function to see (that is: to <i>prove</i>) that we are in the monadic domain, and, with that guarantee, we can proceed in the safety of that domain, not having to frontload any nor every computation that follows with preconditions that would be required outside that monadic domain.</p><p><span style="font-family: courier;">null</span>-check simply vanishes in monadic domains that do not allow that (non-)value.</p><p>Incidentally, here's an oxymoron: '<span style="font-family: courier;">NullPointerException</span>' in a language that doesn't have pointers.</p><p>Here's another oxymoron: '<span style="font-family: courier;">null</span> value,' when '<span style="font-family: courier;">null</span>' means there is no value (of that specified type, or, any type, for that matter). <span style="font-family: courier;">null</span> breaks type-safety, but I get ahead of myself.</p><p>Back on point.</p><p>So, okay: great. We, using the Kleisli arrows, know at every point in that computation that we are in the monadic domain, <i>T,</i> and can chain computations safely in that domain.</p><p>But, wait. There's a glaring issue here. Sure, <i>f<sup>K </sup></i>gets us into the monadic domain, but let's chain the computation. Let's say we have:</p><p><i>g<sup>K</sup> : B </i><span style="background-color: white; color: #202124; font-size: 16px;">→ </span><i>T C</i></p><p>... and we wish to chain, or, functionally: compose <i>f<sup>K </sup></i>and <i>g<sup>K</sup></i>? We get this:</p><p><span style="background-color: white;"><i>g<sup>K</sup></i> <span face="Roboto, arial, sans-serif" style="color: #202124; font-size: 16px;">∘ </span><i>f<sup>K </sup></i>⇒<span style="color: #202124; font-size: 16px;"> <i>A </i></span><span style="color: #202124; font-size: 16px;">→ <i>T B </i></span><span style="color: #202124; font-size: 16px;">→ <i>TT C</i></span></span></p><p>Whoops! We're no longer in the monadic domain <i>T, </i>but at the end of the chained-computation, we're in the monadic domain <i>TT</i>, and what, even, is that? I'm not going to answer that question, because 1) who cares? because 2) where we really want to be is in the domain <i>T, </i>so the real question is: how do we get rid of that extra <i>T</i> in the monadic domain <i>TT </i>and get back into the less-cumbersome monadic domain we understand, <i>T</i>?</p><p></p><ul style="text-align: left;"><li>That's where the join-function, μ, comes in.</li></ul><div>μ : <i>TT A </i><span style="background-color: white; color: #202124; font-size: 16px;">→ <i>T A</i></span></div><div><span style="background-color: white; color: #202124; font-size: 16px;"><i><br /></i></span></div><div><span style="color: #202124;"><span style="background-color: white;">The join-function, </span></span>μ,<span style="background-color: white; color: #202124;"> of a monad, </span><i style="color: #202124;">T,</i><span style="background-color: white; color: #202124;"> states that when you join a monad of type <i>T </i>to a monad of that same type, the result, <i>TT, </i>when joined, simplifies to that (original) monad, <i>T.</i></span></div><div><span style="background-color: white; color: #202124;"><i><br /></i></span></div><div><span style="color: #202124;"><span style="background-color: white;">It's as simple as that.</span></span></div><div><span style="color: #202124;"><span style="background-color: white;"><br /></span></span></div><div><span style="color: #202124;"><span style="background-color: white;">But, then, it's even simpler than that, as the Kleisli arrow anticipates that you're starting in a monadic domain and wish to end up in that domain, so the Kleisli arrow entails the join function, </span></span>μ, 'automagically.' With that understanding, we rewrite standard functional composition to composition under the Kleisli category:</div><div><br /></div><div><i>g<sup>K</sup></i><span style="background-color: white;"> </span><span face="Roboto, arial, sans-serif" style="color: #202124; font-size: 16px;">∘</span><i><sup>K</sup></i><span face="Roboto, arial, sans-serif" style="color: #202124; font-size: 16px;"> </span><i>f<sup>K </sup></i><span style="background-color: white;">⇒</span><span style="color: #202124; font-size: 16px;"> <i>A </i></span><span style="color: #202124; font-size: 16px;">→ <i>T B </i></span><span style="color: #202124; font-size: 16px;">→ <i>T C</i></span></div><div><span style="color: #202124; font-size: 16px;"><i><br /></i></span></div><div><span style="color: #202124;">Which means we can now compose as many Kleisli arrows as we like, and anywhere we are in that compositional-chain, we know we are in our good ole' safe, guaranteed monadic domain.</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;"><b>Practical Application</b></span></div><div><span style="color: #202124;"><b><br /></b></span></div><div><span style="color: #202124;">We've heard of the <span style="font-family: courier;">Maybe</span> monad, which entails semi-determinism, this monad is now part of the core Java language as the <span style="font-family: courier;">Optional</span>-type, with practical application in functional mapping, filtering and finding, as well as interactions with data-stores (e.g.: databases).</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;">Boy, I wish I had that back in the 1990's, developing the Sales Comparison Approach ingest process of mortgage appraisal forms for Fannie Mae. I didn't. I had Java 1.1. A glaring 'problem' we had to address with ingesting mortgage appraisals what that every single field is optional, and, as (sub-)sections depend on prior fields, entire subsections of the mortgage appraisal form were <i>dependently-optional.</i> The solution the engineering team at that time took was to store every field of every row of the 2000 fields of the mortgage appraisal form.</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;">Fannie Mae deals with millions of mortgage appraisals</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;">Each.</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;">Year.</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;">Having rows upon rows (upon rows upon rows) of data tables of null values quickly overloaded database management systems (at that time, and, I would argue, is tremendously wasteful, even today).</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;">My solution was this, as each field is optional, I lifted that value into the monadic domain, that way, when a value was present, follow-on computations, for follow-on (sub-)sections would execute, and, as the process of lifting failed on a <span style="font-family: courier;">null</span>-value, follow-on computations were <i>automagically</i> skipped for absent values. Only values <i>present</i> were stored. Only computations on <i>present</i> values were performed. The Sales Comparison Approach had over 600 fields, all of them optional, many of them <i>dependently-optional, </i>and only the values present in those 600 fields were stored. The savings in data storage was <i>exponentially</i> more efficient for the Sales Comparison Approach section as compared to the storage for the rest of the mortgage appraisal.</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;">Although easy enough, and intuitive, to say, actually implementing Kleisli Arrows in Java 1.1 (the <i>langua fraca</i> for that project) required I first implement the concept of both Function and Functor, using inner classes, then I needed to implement the concept of Monad, then Maybe, then, with monad, I needed to implement the Kleisli Arrow monadic-bind function to be able to stitch together dozens and hundreds of computations together, without one single explicit <span style="font-family: courier;">null</span>-check.</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;">The data told me if they were present, or not, and, once lifted into the monadic domain, the Kleisli arrows stitched together the entire Sales Comparison Approach section, all 600 computations, into a seamless and concise workflow.</span></div><div><span style="color: #202124;"><br /></span></div><div><span style="color: #202124;"><b>Summary</b></span></div><div><span style="color: #202124;"><b><br /></b></span></div><div><span style="color: #202124;">Kleisli arrows: so useful they are recognized as integral to the modern programming paradigm. What's fascinating about these constructs is that they are grounded in provable mathematical forms, from </span>η to μ to Kleisli-composition. This article summarized the mathematics underpinning the Kleisli category and showed a practical application of this pure mathematical form that translated directly into space-efficient and computationally-concise software delivered into production that is still used to this day.</div>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com1tag:blogger.com,1999:blog-4650294074444534066.post-4261356574245641902021-06-01T06:34:00.002-07:002021-06-01T14:46:18.183-07:00June 2021 1HaskellADay Problems and Solutions<p></p><ul style="text-align: left;"><li>Today's #haskell problem: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M06/D01/Exercise.hs">what is 'today' in a data-set</a>. Interesting question. In today's #haskell solution, we<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M06/D01/Solution.hs"> build a SQL query</a>, ... WITH HASKELL! </li></ul><p></p>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com2tag:blogger.com,1999:blog-4650294074444534066.post-43648634276309413992021-05-08T14:07:00.005-07:002021-05-24T22:35:30.974-07:00May 2021 1HaskellADay 1Liners: problems and solutions<ul>
<li>2021-05-24, Monday:<br/>
Map.partitionWithKey's discriminator is<br/>
<code>p :: k -> a -> Bool</code><br/>
But I have a function that discriminates only on the key:<br/>
<code>part :: k -> Bool</code><br/>
write a function that translates my discriminator that can be used by Map.partitionWithKey:<br/>
<code>g :: (k -> Bool) -> (k -> a -> Bool)</code>
<ul>
<li>Social Justice Cleric @noaheasterly:<br/> <code>g = (const .)</code></li>
</ul>
</li>
<li>2021-05-09, Sunday:<br />
<p><strong>THE SEQUEL!</strong></p>
<p>Okay, kinda the same, ... but not:</p>
<p>You have: <code>f :: m a</code><br />
You want: <code>g :: b -> m b</code></p>
<p>Where <code>g</code> runs <code>f</code>, but accepts an argument, <code>b</code>.<br />
<code>g</code> drops the result of <code>f</code> (... on the floor? idk)<br />
<code>g</code> returns the argument <code>b</code> lifted to the domain, <code>m</code></p>
<p>GO!</p>
<ul>
<li>Denis Stoyanov Ant @xgrommx:<br />
<code>g (phantom . pure)</code><br />
This is just joke)</li>
<li>Social Justice Cleric @noaheasterly: <code>(f $>)</code></li>
</ul>
</li>
<li>2021-05-08, Saturday: two-parter
<ol>
<li>You have <code>f :: a -> m b</code><br />
You want <code>g :: a -> m a</code>
<p>That is to say: <code>g</code> is a function that returns the input and drops the output of <code>f</code>.</p>
<p>so:</p>
<code>blah :: (a -> m b) -> (a -> m a)</code></li>
<li>What is a gooder name for the <code>blah</code>-function?</li>
</ol>
<ul>
<li>Jonathan Cast #AJAA #Resist @jonathanccast:<br />
<code>returnArg = (*>) <$> f <*> return</code>
</li>
<li>Social Justice Cleric @noaheasterly:<br />
<code>liftA2 (<*)</code>
</li>
</ul>
</li>
</ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-8016441033081271142021-04-06T22:54:00.010-07:002021-04-22T20:18:05.654-07:00April 2021 1HaskellADay 1Liners Problems and Solutions<p></p><ul style="text-align: left;"><li>2021-04-20, Tuesday:
<p>So, I had this problem</p>
<p>I have <code>pairs :: [(a, IO [b])]</code></p>
<p>but I want <code>pairs' :: IO [(a, b)]</code></p>
<p><code>sequence</code> a gives me something like I don't know what: distributing the list monad, not the IO monad. Implement:</p>
<p><code>sequence' :: [(a, IO [b])] -> IO [(a, b)]</code></p>
<ul><li>p h z @phaazon_:<br /><code>fmap join . traverse (\(a, io) -> fmap (map (a,)) io)</code></li>
<li>lucas卞dicioccio, PhD @lucasdicioccio:
<p>Just to annoy you I'll use the list-comprehension syntax you dislike.</p>
<p><code>solution xs = sequence [fmap (a,) io | (a, io) <- xs]</code></p>
</li>
<li>Benkio @benkio89:<br />
<code>fmap concat . traverse (\(a,iobs) -> fmap (a,) <$> iobs)</code></li>
<li>Social Justice Cleric @noaheasterly<br/>
<code>fmap concat . traverse (getCompose . traverse Compse)</code>
</li>
<li>Social Justice Cleric @noaheasterly<br/>
<code>fmap (concatMap getCompose) . getCompose . traverse Compose. Compose</code>
</li>
<li>Basile Henry @basile_henry: Slightly less polymorphic:<br/>
<code>sequence' = traverse @[] (sequence @((,) _) @IO)</code>
</li>
<li>Basile Henry @basile_henry: I think it's just<br/>
<code>traverse sequence</code> ;)
</li>
<li>Jérôme Avoustin @JeromeAvoustin: there surely is a shorter version, but I could come up with...<br/>
<code>fmap join . sequence . (fmap . fmap) sequence . fmap sequence</code>
</li>
</ul></li>
<li>2021-04-16, Friday:
<p>You have a monad, or applicative, and you wish to execute the action of the latter but return the result of the former. The simplest representation for me is:</p>
<p><code>pass :: IO a -> b -> IO b</code></p>
<p>so:</p>
<p><code>return 5 >>= pass (putStrLn "Hi, there!") </code></p>
<p>would return <code>IO 5</code></p><p>GO!</p>
<ul>
<li>D Oisín Kidney @oisdk <code>flip (<$)</code></li>
<li>ⓘ_jack @Iceland_jack <code>($>)</code></li>
</ul>
</li><li>2021-04-12, Monday:
<p>A function that takes the result of another function then uses that result and the original pair of arguments to compute the result:</p>
<pre>f :: a -> a -> b
g :: b -> a -> a -> c</pre>
<p>so:</p>
<pre>(\x y -> g (f x y) x y)</pre>
<p>curry away the x and y arguments.</p>
</li><li>2021-04-07, Wednesday:<br />you have
<code>(Maybe a, Maybe b)</code><br />you want <code>Maybe (a, b)</code>
<p>If either (Maybe a) or (Maybe b) is <code>Nothing</code><br />then the answer is <code>Nothing</code>.</p>
<p>If both (Maybe a) and (Maybe b) are (Just ...)<br />then the answer is <code>Just (a, b)</code></p>
<p>WHAT SAY YOU?
</p><ul><li>Jérôme Avoustin @JeromeAvoustin: <code>bisequence</code></li>
<li>p h z @phaazon_ with base: <code>uncurry $ liftA2 (,)</code></li>
<li>greg nwosu @buddhistfist: <code>(,) <$> ma <*> mb</code></li></ul><p></p></li></ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-48077564491572108162021-04-01T09:59:00.025-07:002021-04-28T17:28:15.402-07:00April 2021 1HaskellADay Problems and Solutions<p></p><ul style="text-align: left;"><li>2021-04-28: We build a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D28/Exercise.hs">recommendation-system from spotty data</a> for today's #haskell problem. runRecs rekt the run of the ... rektrun? Bah: today's #haskell solution, with <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D28/Solution.hs">implication to the rescue</a>! </li><li>2021-04-26: Today's #haskell problem, on <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D26/Exercise.hs">m̸͈̣̈́̉̉̊̈́y̴̢͌̇̕ ̷̡̗͎̰̠͚̓̈́͠B̷̙͋͊̈̕͘Į̷̻̱͔̼̙͖͚̥̄͝R̴͉̖̻̬̗͕͋̽̉̚͝T̵͈̮͙͚̤̘̦̮͐̓́̔̂͑̋̐̐̄H̶̬̳͔͔̳̀̉̇̋͒D̵̢̡̧̦̖̝͖͕͕̤̊Ȃ̷̧̩̼͔̱͙̟̺̕Y̴̡̢̮̘͛̄̽͛̆̃͌</a> we solve what every Gubmint agency faces every hour of the day: what does this 'TLA' stand for? Today's #haskell solution: Don't mind me. I'm just <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D26/Solution.hs">TLA'ing</a> over here. </li><li>2021-04-23: WHO WOULD WIN THIS FIGHT: Ragnarr Loðbrók or Miyamoto Musashi? Today's #haskell problem gives a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D23/Exercise.hs">bean-counter's approach</a>, ... LITERALLY! Today's #haskell solutions shows that the winner of the Viking-Samurai deth-match is: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D23/Solution.hs">ViewPatterns</a>! ... obviously. 😎<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhDkNqPMmmOV3OJP8eQDQl-QgmOROjJvDf1qZkwKN0JoKcFAsaQgJjWfTTpiXiruoeM63GYzrKRGWE9fYcY0-8WfyRhBfA2Zt4QA-BR4Nw_XYwP-W9remoqDfZXab7ERZFer4NbC127SiB/s700/vikings.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="394" data-original-width="700" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhDkNqPMmmOV3OJP8eQDQl-QgmOROjJvDf1qZkwKN0JoKcFAsaQgJjWfTTpiXiruoeM63GYzrKRGWE9fYcY0-8WfyRhBfA2Zt4QA-BR4Nw_XYwP-W9remoqDfZXab7ERZFer4NbC127SiB/s320/vikings.jpg" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGjsCm4lmsp9rBlNYKjitLT-GYHzldxrNjLMhB8_Ydz1CpuGSeVeEtYOq_6BURBnOm6auurV3ofj36AmiL-utjsG_eEypbHCGl4yyp-2Qy0bvrdCQLzTgKocVg22aYMo3XyzZwJWUzQgEA/s1710/Musashi-Featured-Image.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1710" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGjsCm4lmsp9rBlNYKjitLT-GYHzldxrNjLMhB8_Ydz1CpuGSeVeEtYOq_6BURBnOm6auurV3ofj36AmiL-utjsG_eEypbHCGl4yyp-2Qy0bvrdCQLzTgKocVg22aYMo3XyzZwJWUzQgEA/s320/Musashi-Featured-Image.jpg" width="320" /></a></div><br /></li><li>2021-04-22: In today's #haskell exercise we try to find the opposite of Kung Fu Fighting, and we fail (because there is no opposite of awesome ... besides fail. GEDDIT?) So we try to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D22/Exercise.hs">find the dual of Kung Fu Fighting</a>. Easy, no? "Your WuShu Praying Mantis-style is strong, but can it match my Tiger Claw-style?" Narrator: "We find out the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D22/Solution.hs">thrilling conclusion</a> in today's #haskell solution!" </li><li>2021-04-14: In today's #haskell exercise we learn it requires<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D14/Exercise.hs"> 'Expert Timing' to be 'Kung Fu Fighting.'</a> So, <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D14/Solution.hs">we have fighting; we have noodles</a>. We have everything we need for today's #haskell solution. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRa0BPZ3YCYsxSzjhcctJOMTmeI2ZijWlpg1yDEVkR0IuIa_3Ik4PmUu-rch1_ysdRtBUQpETLfFw5FEaTfyEAwr4EJ88LyP6oPa7jO_DZxzqDbizCOsEYof9w5VUZEd5w4ASYMbOEZYuq/s611/KungFuFighting.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="343" data-original-width="611" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRa0BPZ3YCYsxSzjhcctJOMTmeI2ZijWlpg1yDEVkR0IuIa_3Ik4PmUu-rch1_ysdRtBUQpETLfFw5FEaTfyEAwr4EJ88LyP6oPa7jO_DZxzqDbizCOsEYof9w5VUZEd5w4ASYMbOEZYuq/s320/KungFuFighting.png" width="320" /></a></div><br /></li><li>2021-04-12: For today's #haskell problem we are <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D12/Exercise.hs">lifting a "plain" method into the monadic domain</a> ... yes, I'm influenced by @BartoszMilewski writing. Why do you ask? Today's #haskell solution: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D12/Solution.hs">Function: lifted</a>. </li><li>2021-04-09: We get <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D09/Exercise.hs">all officious</a>, ... sry: 'OFFICIAL' ... with today's #haskell problem. Today's #haskell solution shows us that you haven't met real evil until your TPS-report cover letter is ... <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D09/Solution.hs">Lorem Ipsum</a>. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinAaPIpLyQvcsdglbSoYY2uGSkYN2OLYn1ZtQRvjQyA5nvGhx01bibF1F2gM6oWtpX-N8vr_hTYPlukk8Y-Yxwv1svaxQgdwN9sGb1O5m0PBGgaE4nUAcjKu9vaGVryoDfXM7nrq01SEvF/s1024/Lorem-Ipsum.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="443" data-original-width="1024" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinAaPIpLyQvcsdglbSoYY2uGSkYN2OLYn1ZtQRvjQyA5nvGhx01bibF1F2gM6oWtpX-N8vr_hTYPlukk8Y-Yxwv1svaxQgdwN9sGb1O5m0PBGgaE4nUAcjKu9vaGVryoDfXM7nrq01SEvF/s320/Lorem-Ipsum.png" width="320" /></a></div><br /></li><li>2021-04-08, Thursday: In today's #haskell problem we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D08/Exercise.hs">optionally parse a string</a> into some value of some type. Some how. Today's #haskell solution shows us the sum of the numbers in the string was 42 (... <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D08/Solution.hs">no, it wasn't</a>). </li><li>2021-04-07, Wednesday: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D07/Exercise.hs">decode vs. eitherDecode</a> from Data.Aeson is today's #haskell exercise. In today's #haskell solution we find that <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D07/Solution.hs">it's nice when eitherDecode tells you why it failed</a> to parse JSON. </li><li>2021-04-05, Monday: Today's #haskell exercise is to make a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D05/Exercise.hs">vector that is Foldable and Traversable</a>. Today's #haskell solution gives us Vectors as Foldable and Traversable. <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D05/Solution.hs">YUS</a>! </li><li>2021-04-01, Holy Thursday: In today's #haskell exercise we learn the WHOPR beat the Big Mac. We also learn how to make a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D01/Exercise.hs">safe call to an HTTPS endpoint</a>, but that's not important as the WHOPR beating the Big Mac. "Would you like to play a game?" Today's #haskell solution says: "<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M04/D01/Solution.hs">Yes, (safely, please)</a>." <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis8eZ9WbOrt-3Qqce684x9EnYO-UgG_JFxssk_Z_KA1ZOrNPW9NKKfO-RykhreP8uaAO-R0G1D8a2K2_5ap-zK3bZZ5tZgWO8qetH-l1DMzeY-3qVHstaEd01IvT9hmip65bnXht4fss-r/s445/war-games.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="445" data-original-width="302" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis8eZ9WbOrt-3Qqce684x9EnYO-UgG_JFxssk_Z_KA1ZOrNPW9NKKfO-RykhreP8uaAO-R0G1D8a2K2_5ap-zK3bZZ5tZgWO8qetH-l1DMzeY-3qVHstaEd01IvT9hmip65bnXht4fss-r/s320/war-games.jpg" /></a> <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVuGs8SmKYA_5n1VrKtpEx7rhIfpYFMLIabDDJtcZdGZYYfWDpZkCs_ayacW6yzbZy5iIz9_P53fiiqMquQOsBoLlE8sa8R9Ozm3l22e5Y7XIGLbFMsKC5eGhL0on665dBVVp77-8rRaXX/s1440/wargames-teaser.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="709" data-original-width="1440" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVuGs8SmKYA_5n1VrKtpEx7rhIfpYFMLIabDDJtcZdGZYYfWDpZkCs_ayacW6yzbZy5iIz9_P53fiiqMquQOsBoLlE8sa8R9Ozm3l22e5Y7XIGLbFMsKC5eGhL0on665dBVVp77-8rRaXX/s320/wargames-teaser.png" width="320" /></a></div><br /></div><br /></li></ul><p></p>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-81374176723545991292021-03-23T13:15:00.004-07:002021-03-23T14:34:04.704-07:00March 2021 1HaskellADay 1Liners<p></p><ul style="text-align: left;">
<li>2021-03-23: <p>You have <code>[a]</code> and <code>(a -> IO b)</code>.</p>
<p>You want <code>IO [(a, b)]</code></p><p>That is, you want to pair your inputs to their outputs for further processing in the IO-domain.</p>
<ul><li>Chris Martin @chris__martin: <p><code>\as f -> traverse @ [] @ IO (\a -> f a >>= \b -> </code><p><code>return (a, b)) as</code></p></li>
<li>cλementd Children crossing @clementd:
<p><code>traverse (sequenceA . id &&& f)</code></p>
<p>(actually, <code>tranverse (sequence . (id &&& f))</code>)</p>
<p>Or <code>p traverse (traverse f . dup)</code></p>
</li>
</ul></li>
<li>2021-03-23: You have <p><code>[([a], [b])]</code></p><p>You want <code>([a], [b])</code></p> <p>so: <code>[([1,2], ["hi"]), ([3,4], ["bye"])]</code></p><p>becomes <code>([1,2,3,4],["hi","bye"])</code></p>
<ul><li>karakfa @karakfa: <p><code>conc xs = (concatMap fst xs, concatMap snd xs)</code></p></li></ul>
</li></ul><p></p>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com1tag:blogger.com,1999:blog-4650294074444534066.post-82328703491166990512021-03-01T12:14:00.037-08:002021-03-31T16:15:09.991-07:00March 2021 1HaskellADay Problems and Solutions<p></p><ul style="text-align: left;"><li>2021-03-31, Wednesday: Let's go on <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D31/Exercise.hs">50 last dates</a> for today's #haskell problem. Today's #haskell solution shows us the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D31/Solution.hs">fifty last dates were the fifty best dates</a>. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggzuoHYjQPIk2zm6IOM7HOcnBWxUaLL7O1b6bm9Y-Gg3THAQL1-c40WQlFSkPtcsymiuS3Fei8RPMxbCHAgLl89El-rn33uEB8iKOxXpecnlVvebX5GTaWH8GoO_j_48Jt4SawaVE7jwU_/s1200/fifty-last-dates.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1200" data-original-width="630" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggzuoHYjQPIk2zm6IOM7HOcnBWxUaLL7O1b6bm9Y-Gg3THAQL1-c40WQlFSkPtcsymiuS3Fei8RPMxbCHAgLl89El-rn33uEB8iKOxXpecnlVvebX5GTaWH8GoO_j_48Jt4SawaVE7jwU_/s320/fifty-last-dates.jpg" /></a></div><br /></li><li>2021-03-30, Tuesday: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D30/Exercise.hs">Directorizin' ... WITH STYLE!</a> ... is today's #haskell problem. Today's #haskell solution: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D30/Solution.hs">BEHOLD THE MIGHTY POWER OF THE <*></a>! </li><li>2021-03-29, Monday: Today's #haskell problem tackles <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D29/Exercise.hs">plurality and connectives</a> to list the contents of our Fruits Basket. Today's #haskell solution <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D29/Solution.hs">gives us fruits, in the basket, properly-speaking, thanks to George Boole</a>. </li><li>2021-03-25, Thursday: Today's #haskell problem has me <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D25/Exercise.hs">FORTHing AT THE MOUTH!</a> ... AGAIN! ... no, ... wait ... </li><li>2021-03-23, Tuesday: Let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D23/Exercise.hs">go FORTH!</a> and conquer! for today's #haskell problem. Today's #haskell solution gives us a little FORTHer to go FORTH and FORTH! ... and also <a href="https://github.com/geophf/1HaskellADay/tree/master/exercises/HAD/Y2021/M03/D23">demonstrates Gauss' sum formula ... IN FORTH!</a> ... which is nice. </li><li>2021-03-22, Monday: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D22/Exercise.hs">Fixing-up and validating a JSON-as-string</a> (and don't get me started) is today's #haskell problem. Today's #haskell solution uses Data.Aeson to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D22/Solution.hs">transform some JSON, ... typefully</a>. </li><li>2021-03-19: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D18/Solution.hs">pi</a>. Not pie. Not tau. pi... you know, or: close enough, is served as today's #haskell problem (via <a href="https://twitter.com/AnecdotesMaths">@AnecdotesMaths</a>). <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D19/Solution.hs">PI!</a> for today's #haskell solution. And a pie recipe from Sumeria, if you're in a baking-mood. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbjyFGzjoddw6Tn4HAffldaXDj0s3OE63JyKenaFOScrMQTGr_772KP-LBYlABzXJ6eRelSrUsakePCxGt_vgp6cbvXfkYCGE8Ce-t5ydIARFsXAQgrNPze-qsn-EZdujl-tHjlK2iG0Si/s600/sumerian-pie-recipe.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="600" data-original-width="489" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbjyFGzjoddw6Tn4HAffldaXDj0s3OE63JyKenaFOScrMQTGr_772KP-LBYlABzXJ6eRelSrUsakePCxGt_vgp6cbvXfkYCGE8Ce-t5ydIARFsXAQgrNPze-qsn-EZdujl-tHjlK2iG0Si/s320/sumerian-pie-recipe.jpg" /></a></div><br /></li><li>2021-03-18: Today's #haskell problem is to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D18/Exercise.hs">update lookup tables with new values</a>. Today's #haskell solution gets the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D18/Solution.hs">indices for foo, bar, quux, and ... Joe???</a> Okay. </li><li>2021-03-16: Today's #haskell problem uses <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D16/Exercise.hs">natural language processing</a> to consolidate words in the cloud. et, voilà: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D16/Solution.hs">Grace Hopper wikipedia entry word-cloud, trimmed and stemmed</a>, for today's #haskell solution. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimZXOIBCRvO3BDtO-GLvvB3if3LylZFDBjRYBTstOAcUTNvCpZLP6duBC0INY96j-jSte3KyktcpNacQamjoeiSnR0S0qXJxaUdOaZmc32wtyAMqUr8b6Kqftr4X5kfHVPLdLOkrxB9OCn/s1039/grace-hopper-restemmed-four-or-more-counts-words.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="522" data-original-width="1039" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimZXOIBCRvO3BDtO-GLvvB3if3LylZFDBjRYBTstOAcUTNvCpZLP6duBC0INY96j-jSte3KyktcpNacQamjoeiSnR0S0qXJxaUdOaZmc32wtyAMqUr8b6Kqftr4X5kfHVPLdLOkrxB9OCn/s320/grace-hopper-restemmed-four-or-more-counts-words.png" width="320" /></a></div><br /></li><li>2021-03-15: Today's #haskell problem explores<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D15/Exercise.hs"> Grace Hopper's wikipedia entry as a word-cloud</a> generated by <a href="http://d3js.org">d3js.org</a> for #WomensHistoryMonth Today's #haskell solution <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D15/Solution.hs">removed some obvious things (punctuation and citations)</a> to simplify Grace Hopper's word-cloud. #WomenHistoryMonth<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQm2FbKgNI-0zh8tURJ3p2uxpAo27jk2DoIAegSxJZE6IvqdOCrHIb320Ff0NIJhLDiIBHR-C50RTlmKJvFhdKCpyTN54G0IhuNHn3Pu3tfd4X9Esl6PoPJKMbjOrVSJN3YnFidgKaixav/s1048/grace-hopper-wikipedia-word-cloud.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="542" data-original-width="1048" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQm2FbKgNI-0zh8tURJ3p2uxpAo27jk2DoIAegSxJZE6IvqdOCrHIb320Ff0NIJhLDiIBHR-C50RTlmKJvFhdKCpyTN54G0IhuNHn3Pu3tfd4X9Esl6PoPJKMbjOrVSJN3YnFidgKaixav/s320/grace-hopper-wikipedia-word-cloud.png" width="320" /></a></div><br /></li><li>2021-03-11: It's not every <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D11/Exercise.hs">Tom, Dick, and Harry</a> that can do today's #haskell exercise... In today's #haskell solution <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D11/Solution.hs">you want an id? YOU GOT AN ID</a>! 😤 </li><li>2021-03-09: Let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D09/Exercise.hs">query a directory and do something with each file</a> in that directory for today's #haskell problem. Today's #haskell solution? <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D09/Solution.hs">THAT WAS EASY!</a> ... so! What are we doing tomorrow? 😃 </li><li>2021-03-05: Today we're <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D05/Exercise.hs">shell-scripting</a> ... WITH HASKELL! 😤 Today's #haskell solution says: "<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D05/Solution.hs">Well, hello there, good lookin'!</a>" </li><li>2021-03-04: Today's #haskell problem: you have a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D04/Exercise.hs">time-series of values</a>, not necessary gapless, get the latest value; then, get 'yesterday's' value. Today's #haskell solution gives us some useful <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D04/Solution.hs">functions to navigate a time-series</a> of values. </li><li>2021-03-03: Today's #haskell problem asks: "<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D03/Exercise.hs">Where in the world are these wineries?</a>" Then answers that question. Ooh! Wineries! <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D03/Solution.hs">Wineries all over the globe!</a> is in today's #haskell solution. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCaLuRuqmMwpwotp8qBbaHNUpskvPR36atDH3FuiecMRZB7fxexO3FiqKhQJbwPkcXgGAegxMQMzrRSu7FeJqDo49IHq-qFs6K4KG-eNKCK3GhaRKIOD96KtnCm3ypxN6zMOnukKVu1MMr/s1289/04-Chateau-Ste-Michelle.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="690" data-original-width="1289" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCaLuRuqmMwpwotp8qBbaHNUpskvPR36atDH3FuiecMRZB7fxexO3FiqKhQJbwPkcXgGAegxMQMzrRSu7FeJqDo49IHq-qFs6K4KG-eNKCK3GhaRKIOD96KtnCm3ypxN6zMOnukKVu1MMr/s320/04-Chateau-Ste-Michelle.png" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj00sWFZbU9F8yBI5qvmskZ5KZfEQdVFUqk0TDz1gx5GuWwHnDPTzhhxJFisqFoOdhDt8B9sQTh7wzGyDbTwQPq4L5XCNRCFS7p7szP_eMJPWjenlqDXF1OLn6EZfEp1hn6NNlm-quSVAwq/s1292/03-Castello-di-Amorosa.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="725" data-original-width="1292" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj00sWFZbU9F8yBI5qvmskZ5KZfEQdVFUqk0TDz1gx5GuWwHnDPTzhhxJFisqFoOdhDt8B9sQTh7wzGyDbTwQPq4L5XCNRCFS7p7szP_eMJPWjenlqDXF1OLn6EZfEp1hn6NNlm-quSVAwq/s320/03-Castello-di-Amorosa.png" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBMjNysZYADDPJmQmMN7fb2Ezb7GcQFABjktqzaM4BLP39dbbC87RxwZSu4IMndjIACPGLuFXlIx-nrYZUN3O8L-RtxyywDzEeAhADq2vqAngCxdzJb6ki45kzOzCSE7fHHN6bBOIUpEzf/s1288/02-california.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="687" data-original-width="1288" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBMjNysZYADDPJmQmMN7fb2Ezb7GcQFABjktqzaM4BLP39dbbC87RxwZSu4IMndjIACPGLuFXlIx-nrYZUN3O8L-RtxyywDzEeAhADq2vqAngCxdzJb6ki45kzOzCSE7fHHN6bBOIUpEzf/s320/02-california.png" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi48n_Z45hmV-X_DOCVDl3D7ZfDcygoKlbg5eC5OyHw9dp19EVV7KXSzF_udsNzkAUVdvrixyHV2LhjtEE9Ro_dyoeEsNXj9LMXQpe5FjtLDS2BPO-Mun0b48ysQJufOXgdRxJEna47YWwh/s1280/01-wineries-west-coast-USA.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="683" data-original-width="1280" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi48n_Z45hmV-X_DOCVDl3D7ZfDcygoKlbg5eC5OyHw9dp19EVV7KXSzF_udsNzkAUVdvrixyHV2LhjtEE9Ro_dyoeEsNXj9LMXQpe5FjtLDS2BPO-Mun0b48ysQJufOXgdRxJEna47YWwh/s320/01-wineries-west-coast-USA.png" width="320" /></a></div><br /></li><li>2021-03-02: For today's #haskell problem, let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D02/Exercise.hs">add approved matched data to wineries in the graph-store</a>. The #haskell <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D02/Solution.hs">solution! ... with a pic</a>! <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgabr4RmY7qA-DXv13fpsMOf_l4pSF8dOy2NgYKaQUthyZHXIQDAZbOsk33u04I0jF_clb2YTkYuUqo3VbDT_sSm32Q62fTEE7oaj3AQJG0hakyoSNGDWGA_SDKEI-MB5TNLgIP3t51lI3E/s627/wineries-locations-aliases.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="523" data-original-width="627" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgabr4RmY7qA-DXv13fpsMOf_l4pSF8dOy2NgYKaQUthyZHXIQDAZbOsk33u04I0jF_clb2YTkYuUqo3VbDT_sSm32Q62fTEE7oaj3AQJG0hakyoSNGDWGA_SDKEI-MB5TNLgIP3t51lI3E/s320/wineries-locations-aliases.png" width="320" /></a></div><br /></li><li>2021-03-01: Today's #haskell problem <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D01/Exercise.hs">approves matched wineries</a> for (eventual) storage. We <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M03/D01/Solution.hs">approve wiki-to-graph winery metaphone matches</a> for today's #haskell solution. </li></ul><p></p>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com1tag:blogger.com,1999:blog-4650294074444534066.post-8625124937919834252021-02-01T07:29:00.040-08:002021-02-27T02:30:43.814-08:00February 2021 1HaskellADay Problems and Solutions<p></p><ul style="text-align: left;"><li>2021-02-26: Today's #haskell problem we will be <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D26/Exercise.hs">matching the metaphone'd-wineries</a> from wikidata and from the graph-store. Today's #haskell solution gave us <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D26/Solution.hs">16 good matches from 30 candidates</a>. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1VnggCRzt4ixudnC-QN3Px0O9xausf6NeU335PBT36ZeCDlztPdFF9rqobarQL-TSIYmMNAJUaPI8rXjK7r6D8ppfBvKb0QREIiKnlbFYRhouzuiik6aXeBhnyoB8sqcEutKCxA4_GOL2/s736/screening-candidate-matches.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="736" data-original-width="594" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1VnggCRzt4ixudnC-QN3Px0O9xausf6NeU335PBT36ZeCDlztPdFF9rqobarQL-TSIYmMNAJUaPI8rXjK7r6D8ppfBvKb0QREIiKnlbFYRhouzuiik6aXeBhnyoB8sqcEutKCxA4_GOL2/s320/screening-candidate-matches.png" /></a></div><br /></li><li>2021-02-25: For today's #haskell problem we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D25/Exercise.hs">load the wineries' metaphones to the graph-store</a>. Today's #haskell solution: MWA-HAHA! I HAVE <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D25/Solution.hs">METAPHONES FOR WINERIES</a>! <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggg1sfsl3ezCT0NCLPecjv3PgjhdTF1qcD578WhFCP0s78k7SLhLQNgJz15tNSZPAjTTqDGFwfI4GUezY4-R83maBsvcLw5QwTAO110VCH3gwGXlJH4Fq8yS0DfjRFJcIIYx1emjTH-SaZ/s673/wineries-metaphones.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="586" data-original-width="673" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggg1sfsl3ezCT0NCLPecjv3PgjhdTF1qcD578WhFCP0s78k7SLhLQNgJz15tNSZPAjTTqDGFwfI4GUezY4-R83maBsvcLw5QwTAO110VCH3gwGXlJH4Fq8yS0DfjRFJcIIYx1emjTH-SaZ/s320/wineries-metaphones.png" width="320" /></a></div><br /></li><li>2021-02-24: "<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D24/Exercise.hs">What's today's date?</a>" is today's #haskell problem. For today's #haskell solution, I think I found the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D24/Solution.hs">successor to "Hello, world!"</a></li><li>2021-02-23: Today's #haskell exercise involves <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D23/Exercise.hs">calling an external process with a winery and reading the double-metaphone encoded result</a>. Today's #haskell solution <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D23/Solution.hs">tied our wiki- and graph-winery data to an external name-categorizing app</a>. </li><li>2021-02-22: We now have a graph-store of wines, wineries, and wine-reviews, and wikidata, too! One Direction (no, not the boy-band) we can go is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D22/Exercise.hs">to merge the wikidata to our knowledge base</a>. Project! Today's #haskell solution: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D22/Solution.hs">(graph) wineries and (wikidata) wineries</a>. </li><li>2021-02-19: Okay, we have our ~120k wine-reviews uploaded to a graph-store, great! <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D19/Exercise.hs">Did we do it correctly?</a> Hm. Today's Haskell problem. Today's #haskell solution asks: "Duplicate wine reviews? <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D19/Solution.hs">What duplicate wine reviews?</a> Blink, blink." </li><li>2021-02-18: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D18/Exercise.hs">Adding prices and scores</a> to the unicoded wine-reviews in the graph-store is today's #haskell problem. Boom! Today's #haskell solution gives us <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D18/Solution.hs">prices, scores, and wine-reviews</a> now in the graph-store. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXyQsVZUCSUCwjTKlxbx03WkaGtfkj_NrMZBn7ynMi6JGQSSaK7KVwn6NJD7pZxlifE4kEjPQ9ZBFA_BTslWFqrXJ2cOpI_FXsE6344s6ydlHwMx88zKoVICXhAN1GyeJm41KD2enKc-_N/s867/wine-reviews-with-scores-and-prices.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="867" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXyQsVZUCSUCwjTKlxbx03WkaGtfkj_NrMZBn7ynMi6JGQSSaK7KVwn6NJD7pZxlifE4kEjPQ9ZBFA_BTslWFqrXJ2cOpI_FXsE6344s6ydlHwMx88zKoVICXhAN1GyeJm41KD2enKc-_N/s320/wine-reviews-with-scores-and-prices.png" width="320" /></a></div><br /></li><li>2021-02-17: Today's #haskell problem is yesterday's Haskell problem: <a href="https://github.com/geophf/1HaskellADay/tree/master/exercises/HAD/Y2021/M02/D17">saving out a CSV-file</a>, but this time, we're going to save the unicode points: 'good'! Today's #haskell solution: Yay! <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D17/Solution.hs">Properly encoded unicode</a>! </li><li>2021-02-16: Today's #haskell problem is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D16/Exercise.hs">to correct unicoded wine-reviews, then to save them in a CSV file</a> for eventual upload to a graph-store. For today's #haskell solution, we came, we saw, we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D16/Solution.hs">saved CSV, ... unicode points not quite properly encoded</a>. </li><li>2021-02-15: Today's #haskell problem looks for <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D15/Exercise.hs">errors in the wine-reviews JSON file</a> which makes it invalid. Today's #haskell solution fixes JSON with a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D15/Solution.hs">custom-build scanner</a>. </li><li>2021-02-12: Today's #haskell problem: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D12/Exercise.hs">unicode, properly encoded for Text</a>. Imagine that. Today's #haskell solution <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D12/Solution.hs">SOLVES the unicoding-problem ... except that it doesn't</a>. :/ </li><li>2021-02-08: In today's #haskell problem we tackle <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D08/Exercise.hs">wading through wine-reviews to upload</a> to the graph-store. Today's #haskell solution: we are able to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D08/Solution.hs">upload some (1600+) wine-reviews</a> so far. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXS_pWK_Evdbuu625dVo_JDef8tkFukE4rFreg9P0FLFdVyoFtYcn7W4A7nJenW4_lczGTqKX5rZ4PRQfdsA8sQFc7f6hUaUtsrRjLd6tKYUSbT_w48792Ibe6H0dip4ape70ojv_PRPyq/s623/first-1000-reviews.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="525" data-original-width="623" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXS_pWK_Evdbuu625dVo_JDef8tkFukE4rFreg9P0FLFdVyoFtYcn7W4A7nJenW4_lczGTqKX5rZ4PRQfdsA8sQFc7f6hUaUtsrRjLd6tKYUSbT_w48792Ibe6H0dip4ape70ojv_PRPyq/s320/first-1000-reviews.png" width="320" /></a></div><br /></li><li>2021-02-05: Now that we've identified duplicates in our wine graph-store, today's #haskell problem is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D05/Exercise.hs ">to eliminate duplicates</a>. In today's #haskell solution we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D05/Solution.hs">removed duplicate wine-labels and verified no duplicate wineries</a>, as well. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFXI5kWLpfPWfd3HdNsisBTX8kD1xsb9qOBDrK5qrDzofuQzqESbK2B5gKm-4cIATAmIH40N-hs8CMTtgOvvUJtxWPaSeYBqtYygIIoqdglp3e1Im1ovDLbO6W_DR4n5cCuufqt-7-AK5M/s697/wine-with-multiple-reviewers.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="627" data-original-width="697" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFXI5kWLpfPWfd3HdNsisBTX8kD1xsb9qOBDrK5qrDzofuQzqESbK2B5gKm-4cIATAmIH40N-hs8CMTtgOvvUJtxWPaSeYBqtYygIIoqdglp3e1Im1ovDLbO6W_DR4n5cCuufqt-7-AK5M/s320/wine-with-multiple-reviewers.png" width="320" /></a></div><br /></li><li>2021-02-04: For today's #haskell problem with look at <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D04/Exercise.hs">data duplication in the graph-store</a> (particularly: duplicated wine-labels). Today's #haskell solution shows which <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D04/Solution.hs">wines are duplicates</a> (and triplicates, and ... megalons?) <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpU5qQ0EOuYsX8inCYYZJ3GbmqN2l21ew-U0mijU66SwU_8B-z9mf4rTtKOAuJP5TgZ2fTuppuP9tBv8Xey1jHeKccRpppg-LFR8htqOgn2FwJrGxqcq2aBroz5cMIYMuDkj0yNW8qcP3h/s622/duplicate-wine-and-reviewer.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="513" data-original-width="622" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpU5qQ0EOuYsX8inCYYZJ3GbmqN2l21ew-U0mijU66SwU_8B-z9mf4rTtKOAuJP5TgZ2fTuppuP9tBv8Xey1jHeKccRpppg-LFR8htqOgn2FwJrGxqcq2aBroz5cMIYMuDkj0yNW8qcP3h/s320/duplicate-wine-and-reviewer.png" width="320" /></a></div><br /></li><li>2021-02-03: Today's #haskell problem looks at <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D03/Exercise.hs">adding wine reviews (with some optional data)</a> to the graph-store. Today's #haskell solution we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D03/Solution.hs">uploaded a (very (very)) small subset of wine-reviews, prices and ratings</a> to the graph-store. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUIyz6_C1IyYcAXHk1cM0WMV7ZN0wjWC31Nk4Ilh9akNatNPObuddX_QyZutKSmLWyTAk6xtqPUOezvfb27Xv_1NKGuk4YhFDHkwdHO4cJ9SULJRe5K4p6whjKPjhagHXWusi-gVMd6oCl/s999/reviews-scores-prices.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="783" data-original-width="999" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUIyz6_C1IyYcAXHk1cM0WMV7ZN0wjWC31Nk4Ilh9akNatNPObuddX_QyZutKSmLWyTAk6xtqPUOezvfb27Xv_1NKGuk4YhFDHkwdHO4cJ9SULJRe5K4p6whjKPjhagHXWusi-gVMd6oCl/s320/reviews-scores-prices.png" width="320" /></a></div><br /></li><li>2021-02-02: Enhancing graph-store data. From the @kaggle wine-taster data-set, let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D02/Exercise.hs">extract and add the twitter handles</a> of those who have them. Today's #haskell solution adds the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D02/Solution.hs">wine-reviewers' twitter handles</a> to the graph-store. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0vTMDvC6FQcTkq_aOVnOigDxpZbVB2Fyz8e2zH5J7ddnvGRs1KpWEsP-1zv_nrVl7rCoCsF1vZfPNgJguodeiplk0F1as6lLlr7nIha2CPz5nQj8yyUmMIWc1GhyYZnFirscAd9pEkJd5/s622/roger-voss-twitter.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="599" data-original-width="622" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0vTMDvC6FQcTkq_aOVnOigDxpZbVB2Fyz8e2zH5J7ddnvGRs1KpWEsP-1zv_nrVl7rCoCsF1vZfPNgJguodeiplk0F1as6lLlr7nIha2CPz5nQj8yyUmMIWc1GhyYZnFirscAd9pEkJd5/s320/roger-voss-twitter.png" width="320" /></a></div><br /></li><li>2021-02-01: Today's #haskell problem: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D01/Exercise.hs">counting 'dupe?' rows</a> in a CSV file over HTTPS. Today's #haskell solution ponders: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M02/D01/Solution.hs">what is that 'dupe?' column for</a>, anyway? </li></ul><p></p>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-84084836257525521892021-01-21T10:43:00.007-08:002021-01-29T07:10:59.941-08:00January 2021 1HaskellADay 1Liners<ul style="text-align: left;"><li>2021-01-28: Opposite problem:<br />You have: [(a, Set b)]<br />you want: [(a, b)]<br />e.g.: [("hi", fromList [1,2,3]), ("bye", fromList [4,6,7]) -><br />[("hi",1),("hi",2),("hi",3),("bye",4),("bye",6),("bye",7)]<br />Interestingly, Set is not a Monad. wut. How do you get around that problem?</li><ul><li>D Oisín Kidney @oisdk (>>= traverse toList)</li><li></li><li>mine: concatMap (sequence . second Set.toList)</li></ul><li>2021-01-28: <br />We have [(Set a, b)]<br />we want [(a, b)] <br />where each element of Set a is paired with b, e.g.:<br />[(fromList [1,2,3], 'a'), (fromList [4,5,6], 'b')]<br />becomes<br />[(1,'a'),(2,'a'),(3,'a'),(4,'b'),(5,'b'),(6,'b')]</li><ul><li>Steve "wash your hands" Trout @strout:<br />concatMap (uncurry (liftA2 (,)) . bimap toList pure)</li>
<li>insatiable mask wearer @tim_1729<br />[(a,b) | (s,b) <- xs, a <- (toList s)]</li></ul><li>Today, 2021/01/21, is:</li><ol style="text-align: left;"><li>Can be written with only 3 digits, What other dates can be so written? Also:</li><li>a day where the month and day are NOT amalgamation the year. But which dates are amalgamations?</li></ol></ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-36166250495168962202021-01-20T11:53:00.014-08:002021-01-30T07:25:42.542-08:00January 2021 1HaskellADay Problems and Solutions<p></p><ul style="text-align: left;"><li>2021-01-29: Ambitious! Let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D29/Exercise.hs">upload some indexed wineries with geo-locations</a> to the graph-store for today's #haskell problem! For today's #haskell solution <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D29/Solution.hs">we added geo-locations and wikidata QNames for some wineries</a>, with shout-outs to @oisdk and @tim_1729, incorporating their #1Liner answers into the solution. </li><li>2021-01-27: We continue updating our wine-graph with wikidata. Today we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D27/Exercise.hs">update countries in the graph with wikidata QName values</a>. Today's #haskell solution corrects the names of the countries and adds their wikidata QNames, or, put another way: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D27/Solution.hs">O? Canada?!? NANI</a>??? <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix7Mn1bLmJSOlp_qDNRIAyEaHN61uunUSxYkfsfB2wsrhzQrFxZJVHaeTgaNmnbM4JREdyCTKsaQWoO9TSVnKRwERPbgg7UBlL3fLUI6EljCc8jHxe5FHEIFj9t-7MR-zlNW7poc47yabC/s616/o-canada-qid.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="521" data-original-width="616" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix7Mn1bLmJSOlp_qDNRIAyEaHN61uunUSxYkfsfB2wsrhzQrFxZJVHaeTgaNmnbM4JREdyCTKsaQWoO9TSVnKRwERPbgg7UBlL3fLUI6EljCc8jHxe5FHEIFj9t-7MR-zlNW7poc47yabC/s320/o-canada-qid.png" width="320" /></a></div><br /></li><li>2021-01-26: For today's #haskell problem <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D26/Exercise.hs">we compare neo4j graph data to wikidata</a> for wineries now, and what is the "No Country"? And how do I get citizenship there? </li><li>2021-01-25: Okay, looking at <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D25/Exercise.hs">countries aliased between wikidata and a neo4j graph</a> for today's #haskell problem. Today's #haskell solution <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D25/Solution.hs ">loads then uses a graph</a> to resolve aliased country names. </li><li>2021-01-22: Today's #haskell problem: we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D22/Exercise.hs">inject countries of wineries</a> extracted from @wikidata into the mix to ... simplify (?) things? ... wait? There're countries mismatched, too? How ... surprising. 🙄 Today's #haskell solution shows us that wine is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D22/Solution.hs">"No Country"</a> for old men. ... wait ... wut? </li><li>2021-01-21: Today's #haskell problem is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D21/Exercise.hs">to compare wineries</a> from @wikidata to those in a @neo4j graph. Also. Did you know that there's a winery in Oregon named "Sweet Cheeks"? Now you do. You're welcome. Today's #haskell solution shows that <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D21/Solution.hs">125 wineries match, more than 400 don't</a>. Lots of aliasing work ahead of us. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHiR7W69tyy3i_NNySXykbL0QjMVJjPK0n_CGLCQpnyRmeA_ivtzl9Ko1Dj4IEpjABKy2u3-0d-dcd4F8DerWVe_2gf3jPcI-aZ1vy3xIrTGC55dzcJVMgWZti2uphJhUJiTsPUNdCVgNR/s615/Sweet-cheeks-winery.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="514" data-original-width="615" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHiR7W69tyy3i_NNySXykbL0QjMVJjPK0n_CGLCQpnyRmeA_ivtzl9Ko1Dj4IEpjABKy2u3-0d-dcd4F8DerWVe_2gf3jPcI-aZ1vy3xIrTGC55dzcJVMgWZti2uphJhUJiTsPUNdCVgNR/s320/Sweet-cheeks-winery.png" width="320" /></a></div><br /></li><li>2021-01-20: Today's #haskell problem asks you to parse <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D20/Exercise.hs">wineries and their geo-locations</a> from a JSON file. Simple problem; <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2021/M01/D20/Solution.hs">simple solution</a>. Also: wine a bit. It helps. </li></ul><p></p>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-15748375715865242182020-12-01T06:23:00.022-08:002020-12-23T17:11:07.133-08:00December 2020 1HaskellADay Problems and Solutions<p></p><ul style="text-align: left;"><li>2020-12-22: Monads are burritos, but today's #haskell problem brings together <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D22/Exercise.hs">the whole enchilada</a>! In today's #haskell solution we find that whole enchilada is a hot tamale! ... and also <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D22/Solution.hs">map all the air bases of an alliance</a>. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKIn8D0rNKP_XYSE4_MuLi1EvLGKcOTKruPV2wOeeV-GVSEIxRKx18bYNqafLBXA-CdY-bcON18T3tc1KI8QOykpmZ94IJ6BjPwYAbTis0VnEt5fg4zELXYLH9sEylSubCuaZZDkkLVQNe/s1237/five-power-alliance-with-airbases.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1237" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKIn8D0rNKP_XYSE4_MuLi1EvLGKcOTKruPV2wOeeV-GVSEIxRKx18bYNqafLBXA-CdY-bcON18T3tc1KI8QOykpmZ94IJ6BjPwYAbTis0VnEt5fg4zELXYLH9sEylSubCuaZZDkkLVQNe/s320/five-power-alliance-with-airbases.png" width="320" /></a></div><br /></li><li>2020-12-21: Collecting the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D21/Exercise.hs">airbases for all the countries of an alliance</a> from the graph-store is today's #haskell exercise. Today's #haskell solution shows how to work with the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D21/Solution.hs">`withArray` Aeson</a> function. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit4HKG2ffaL8LwqOkhOvWoTBJTYA68sDoyolIqHoVTx_qSkSCrxc0bUom_t-7KAIlyfJeipNAEyI6PRfycCuFzWn6lTgwP3kw9mZfawQpxwhLHmBRlj1V2uEkWzZsu2thbc4tPLU6ONoS2/s1053/five-powers-with-air-bases.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="745" data-original-width="1053" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit4HKG2ffaL8LwqOkhOvWoTBJTYA68sDoyolIqHoVTx_qSkSCrxc0bUom_t-7KAIlyfJeipNAEyI6PRfycCuFzWn6lTgwP3kw9mZfawQpxwhLHmBRlj1V2uEkWzZsu2thbc4tPLU6ONoS2/s320/five-powers-with-air-bases.png" width="320" /></a></div><br /></li><li>2020-12-18: For today's #haskell problem, we extract <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D18/Exercise.hs">an alliance, its member countries, and their capitals from the graph-store to display these data on a global-viewer</a>, such as google Earth. For today's #haskell solution, with #KML and @neo4j, we see that this is an <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D18/Solution.hs">alliance that nearly spans the globe</a>! <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLnfvhpI3ZaZ1X2JTcdKVmmoXs1mlkIFVQ8N4aRfzJvL1zmc6jvQprENMB7ywgwQMsj7pV-Wv-CP9F8ymWqoztj-KHYPC3epuH997yG9A6x3JqJ6SQB45ZuinKZvpa459E0-7kD4DiToco/s1288/five-power-from-graph.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="593" data-original-width="1288" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLnfvhpI3ZaZ1X2JTcdKVmmoXs1mlkIFVQ8N4aRfzJvL1zmc6jvQprENMB7ywgwQMsj7pV-Wv-CP9F8ymWqoztj-KHYPC3epuH997yG9A6x3JqJ6SQB45ZuinKZvpa459E0-7kD4DiToco/s320/five-power-from-graph.png" width="320" /></a></div><br /></li><li>2020-12-16: Extracting an <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D16/Exercise.hs">alliance and its member countries</a> from a graph store is today's #haskell problem. In today's #haskell solution we find that, hm, <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D16/Solution.hs">marshalling aggregated data</a> is more than a bit of work! </li><li>2020-12-15: "<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D15/Exercise.hs">What is the capital of Singapore?</a>" for today's #haskell problem. Today's #haskell solution shows that the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D15/Solution.hs">capital of Singapore is ... well: SINGAPORE</a>! YAY! <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio750aggpeRn0_zupadzn-_izDHw7wxlOjVrkXhytpC6qibs4S14Gz6BXsxZRpviMTxg7pbHlV26JZxUK3UFYhOd4IY7JhZ8smAKSMFe7fbxl7BeFzvVCpMyXsEQRBE34pvQ1yDS7KoSyw/s616/singapore.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="516" data-original-width="616" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio750aggpeRn0_zupadzn-_izDHw7wxlOjVrkXhytpC6qibs4S14Gz6BXsxZRpviMTxg7pbHlV26JZxUK3UFYhOd4IY7JhZ8smAKSMFe7fbxl7BeFzvVCpMyXsEQRBE34pvQ1yDS7KoSyw/s320/singapore.png" width="320" /></a></div><br /></li><li>2020-12-11: For today's #haskell problem we will be <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D11/Exercise.hs">adding lats and longs to country capitals</a> in our graph-store. <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D11/Solution.hs">Capitals now have lats/longs in the graph-store</a>.</li><li>2020-12-10: Today's #haskell problem is to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D10/Exercise.hs">relink capitals from aliases to source countries</a>. Today's #haskell solution clarified the problem, then provided a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D10/Solution.hs">data-correction-solution</a>. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL38xeZTtqhyNiboBvL7KmPAjeBf2IQWw2XW7QpLY_WCN7_0UyWe0m1AvYoji_UxPj5SUyB8h8mTtrFjFy07ENhpxmWh3CBHAY9ZrAXF2EUK0eTF_OhMgAsigSJB23j68wnlLtgxcSy9Ms/s614/aliased-capitals.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="515" data-original-width="614" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL38xeZTtqhyNiboBvL7KmPAjeBf2IQWw2XW7QpLY_WCN7_0UyWe0m1AvYoji_UxPj5SUyB8h8mTtrFjFy07ENhpxmWh3CBHAY9ZrAXF2EUK0eTF_OhMgAsigSJB23j68wnlLtgxcSy9Ms/s320/aliased-capitals.png" width="320" /></a></div><br /></li><li>2020-12-09: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D09/Exercise.hs">Reassociating alliances from alias nodes to their source country nodes</a>. Today's #haskell solution: and we update aliased-alliances-... <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D09/Solution.hs">oops! Unicode. Joy</a>. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP8Kgl8bwVfLg32tmJPoD7CXagmucdpDIUrTuxASRssM_jXGW4Nc3TF3mgBeDJkv3d4SDnZ0xr7MB9x0C8R2ytAgjGnP8IcmHH9FEVGF14jlJl929cqkwdXa7tzFO9vpmjRE7ESnkZmuw6/s930/aliases-alliances.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="781" data-original-width="930" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP8Kgl8bwVfLg32tmJPoD7CXagmucdpDIUrTuxASRssM_jXGW4Nc3TF3mgBeDJkv3d4SDnZ0xr7MB9x0C8R2ytAgjGnP8IcmHH9FEVGF14jlJl929cqkwdXa7tzFO9vpmjRE7ESnkZmuw6/s320/aliases-alliances.png" width="320" /></a></div><br /></li><li>2020-12-07: For today's #haskell problem, we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D07/Exercise.hs">filter out unicode points in both countries and their aliases</a>, ... but we also ask: is filtering the right way to go, or are unicode points being properly represented in JSON by Data.Aeson? Today's #haskell solution<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D07/Solution.hs"> provides aliases to country names</a> (... even as we add some manually ... *cough* #PleaseIgnoreTheManBehindTheCurtain) </li><li>2020-12-03: Today's #haskell problem: adding alias names to a country ... <i>should</i> be simple? <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D03/Exercise.hs">BUT UNICODE</a>! :( Today's #haskell solution: UNICODE FIXED FOR ALIASES! WOOT! ... but what about <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D03/Solution.hs">for the source countries?</a> IM CRIE! 😭 </li><li>2020-12-02: Yesterday, we triaged data for correction. Today #haskell problem is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D02/Exercise.hs">data correction, part I: adding `new` countries</a> we missed before. Today's #haskell solution: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D02/Solution.hs">o, Guinea-Bissau</a>, be ye no longer an orphan, but be home, now, in Africa! <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOsEzOLSahUEtaxErF8Ypp67mRD7iqajWtiDDZhcI9xVo-e3ZuIdBsVY3b50CBAsLTb9EoM8yNGLf3FqFZQKY2Grj_rUU3TiyhyphenhyphenjDvdD9JjX0Ssi0VfDMu2occhX46ym2YRoIDLrwfsPk1/s612/guinea-bissau.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="514" data-original-width="612" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOsEzOLSahUEtaxErF8Ypp67mRD7iqajWtiDDZhcI9xVo-e3ZuIdBsVY3b50CBAsLTb9EoM8yNGLf3FqFZQKY2Grj_rUU3TiyhyphenhyphenjDvdD9JjX0Ssi0VfDMu2occhX46ym2YRoIDLrwfsPk1/s320/guinea-bissau.png" width="320" /></a></div><br /></li><li>2020-12-01: Data correction. Half the problem of data-correction is to realize that you must do a data-correction. The other half of half the problem is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D01/Exercise.hs">to gather the data that needs to be corrected, along with the context of the correction</a>: today's #haskell problem. Today's #haskell solution shows that the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M12/D01/Solution.hs">concept of triage</a> is so helpful in setting up to solve data-correction problems. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZc5zWlquDK6b-0d7HvecriG4czqBrh7_nn9XrEKTOpaoRYZrRodnttiVy0D3XgdDWMlYdDcJdtNbhWdsjjogSEz6IpVkmx2cHISW4gNwthnMUz47PYxXgtAw1D-uwNkew8f1Z4u47ngsn/s789/usa-aliasing.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="515" data-original-width="789" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZc5zWlquDK6b-0d7HvecriG4czqBrh7_nn9XrEKTOpaoRYZrRodnttiVy0D3XgdDWMlYdDcJdtNbhWdsjjogSEz6IpVkmx2cHISW4gNwthnMUz47PYxXgtAw1D-uwNkew8f1Z4u47ngsn/s320/usa-aliasing.png" width="320" /></a></div><br /></li></ul><p></p>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-61743733920457767282020-11-13T11:02:00.001-08:002020-11-13T11:02:30.880-08:00November 2020 1HaskellADay 1Liner problems and solutions<ul style="text-align: left;"><li> In my <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Data/XHTML.hs">Data.XHTML</a>
library <p><code>printXML xml = (\elt -> printElementWithOffset elt 0 >> return elt) (rep xml)</code></p>Curry away the <code>xml</code>-argument to the <code>printXML</code>-function </li></ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com2tag:blogger.com,1999:blog-4650294074444534066.post-6135228873524825502020-11-03T09:59:00.026-08:002020-11-29T13:39:18.765-08:00November 2020 Haskell Problems and Solutions<p></p><ul style="text-align: left;"><li>2020-11-27: Is the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D27/Exercise.hs ">morse code table generated from a graph</a> better than by-hand? In today's #haskell problem, WE FIND OUT! 😤 Today's #haskell solution shows I did code the morse table by hand correctly! *whew* and also show how to extract data from a graph-store. And! has <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D27/Solution.hs">Konami's super-secret cheat-code</a>! ^^vv<><>ba (shh! Don't tell anyone!) <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2bns6dwV6VfxjgPDYbuv5QPlc2njMvbJssUoKcF7JE75meWFzsv0Sn77RdoXIy-xbAoF9d61gDicOtRp1kxnNLAOZDM0JRepmmLP2eb_m1nRqYBH59YLaVgfOinz24X_QbyZCQTO5ZF6b/s613/morse-graph.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="517" data-original-width="613" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2bns6dwV6VfxjgPDYbuv5QPlc2njMvbJssUoKcF7JE75meWFzsv0Sn77RdoXIy-xbAoF9d61gDicOtRp1kxnNLAOZDM0JRepmmLP2eb_m1nRqYBH59YLaVgfOinz24X_QbyZCQTO5ZF6b/s320/morse-graph.png" width="320" /></a></div><br /></li><li>2020-11-25: 'Lorem Ipsum' never looked so good ... <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D25/Exercise.hs">IN MORSE CODE</a>! :< Today's #haskell problem. Today's #haskell solution shows that <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D25/Solution.hs">Cicero had words</a>. Yes, he did. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiX7ym9b_nfqe0FX3lddodxUEwjppLJyvPv8MMbXjR-KZ5xeKS6xp_e40z1vffy-RKyRnJRLolak9qXSE-LEMiKm-2j7m9zqQzsePFxr6fmrjc_-d8oWfheeJqbtGYNOjG15UYRbVcb3qC/s679/morse-code.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="525" data-original-width="679" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiX7ym9b_nfqe0FX3lddodxUEwjppLJyvPv8MMbXjR-KZ5xeKS6xp_e40z1vffy-RKyRnJRLolak9qXSE-LEMiKm-2j7m9zqQzsePFxr6fmrjc_-d8oWfheeJqbtGYNOjG15UYRbVcb3qC/s320/morse-code.png" width="320" /></a><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtL1Dnpc6OCsaPIsE4CN0NmYZqMzuxsUf9ID4O9_Gg6GinGVNKszmuzsMqx_QWqnbqm8zyxvT0X2msUskjsxxDsIcA_4MdWrx2tx1jNLxTOLDK3UikdnaWaqWsOBmGZz7bL_XpfNODB_UZ/s574/cicero-morse.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="142" data-original-width="574" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtL1Dnpc6OCsaPIsE4CN0NmYZqMzuxsUf9ID4O9_Gg6GinGVNKszmuzsMqx_QWqnbqm8zyxvT0X2msUskjsxxDsIcA_4MdWrx2tx1jNLxTOLDK3UikdnaWaqWsOBmGZz7bL_XpfNODB_UZ/s320/cicero-morse.png" width="320" /></a></div><br /></div><br /></li><li>2020-11-23: Today's #haskell problem: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D23/Exercise.hs">ALLIANCES o' the WORLD! UNITE!</a> (like Wonder Twin powers). As today IS <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D23/Solution.hs">Tuesday, it IS Belgium</a>! Displaying the countries of NATO. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDeiaJCJA8tpRV4WgaxkcuH4QVe1Q1ty8eZbfZ1qN50Q4Lr-CMmKcFDFmX-X6dP1nJRXeB57UQxErgLy_aKFlt5bCiAOJa6GFn1_Ggzvaw8-Fa-HLQGJBptCEwVyiOXhCY60eh3-HsF1vU/s1288/nato.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="749" data-original-width="1288" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDeiaJCJA8tpRV4WgaxkcuH4QVe1Q1ty8eZbfZ1qN50Q4Lr-CMmKcFDFmX-X6dP1nJRXeB57UQxErgLy_aKFlt5bCiAOJa6GFn1_Ggzvaw8-Fa-HLQGJBptCEwVyiOXhCY60eh3-HsF1vU/s320/nato.png" width="320" /></a></div><br /></li><li>2020-11-20: If today WERE Tuesday, it would be ... Belgium. Today is Friday, however. (whispered: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D20/Exercise.hs">but it's still Belgium</a>). Today's #haskell problem: render a country's air-power as KML to display on <a href="https://earth.google.com">earth.google.com</a>, or some such-like. Today is Friday, so this must be ... <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D20/Solution.hs ">Bruxelles</a>! ... I'll allow it. Today's #Haskell solution maps Brussels and all the air bases of Belgium. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9AUr2jzGsNRJRq9kCSIEQExe-9pxsLZdQpzwQqi7AfPz2mkLyeY6Z1zcLwxcr8vKpyyJ7gqnxfGL91gBERg17GWWphVUW8MTWlngAPk9B8m3CW6ci7_by-3ggdc85JN71er-1ZRGw1gO4/s1076/google-earth-splash-page.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="686" data-original-width="1076" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9AUr2jzGsNRJRq9kCSIEQExe-9pxsLZdQpzwQqi7AfPz2mkLyeY6Z1zcLwxcr8vKpyyJ7gqnxfGL91gBERg17GWWphVUW8MTWlngAPk9B8m3CW6ci7_by-3ggdc85JN71er-1ZRGw1gO4/s320/google-earth-splash-page.png" width="320" /></a><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhEC-fWzDhvJwdFpDfn4_sF9a-oS1VqH0OtSi9-165b9zdHHGPJn2WKEtveS2nhueNXAQzfJXNAc058lwxmDMOwVT4ph_AYM_E-kH7LhV-kIyvPcudLeyEBVYh4dZhLFCrFHWqtFIbHOPz/s1233/belgian-air-power.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="639" data-original-width="1233" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhEC-fWzDhvJwdFpDfn4_sF9a-oS1VqH0OtSi9-165b9zdHHGPJn2WKEtveS2nhueNXAQzfJXNAc058lwxmDMOwVT4ph_AYM_E-kH7LhV-kIyvPcudLeyEBVYh4dZhLFCrFHWqtFIbHOPz/s320/belgian-air-power.png" width="320" /></a></div><br /></div><br /></li><li>2020-11-18: As yesterday's problem of enhancing countries with additional information was SO EASY 🙄 for today's #haskell we'll take what we learned yesterday and <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D18/Exercise.hs">enhance our stored continents</a> with <a href="http://wikidata.org">wikidata.org</a> information. I'll <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D18/Solution.hs">let the band Toto explain</a> today's #Haskell solution. "I BLESSED THE QID IN AAAAAAFRICA!" 🎵🎶 Thanks, fellahs. 🙄😎 <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzw7n7eMaQNaHBjc74yOdyzkTCiZcw9pb0UPwg4IwxCGytXo8Q5Coz2Yvf9V1g7a-8JDzspCtRkalMWg0fAOnFBSMe21YrlsFvfZU0K5uPWcbYkQzmcs3tpxXiDCu_TZXNVNg0Eev1-yVb/s613/qid-in-Africa.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="513" data-original-width="613" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzw7n7eMaQNaHBjc74yOdyzkTCiZcw9pb0UPwg4IwxCGytXo8Q5Coz2Yvf9V1g7a-8JDzspCtRkalMWg0fAOnFBSMe21YrlsFvfZU0K5uPWcbYkQzmcs3tpxXiDCu_TZXNVNg0Eev1-yVb/s320/qid-in-Africa.png" width="320" /></a></div><br /></li><li>2020-11-17: We find out <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D17/Exercise.hs">capitals of ... um: 'thingies' (?)</a> from <a href="http://wikidata.org">wikidata.org</a> for today's #haskell problem. Belgium has a wikidata.org q-id; captured in our knowledge graph. Belgium has a capital, too: Brussels, along with a lat/long coordinate; also captured. Today's #haskell solution was to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D17/Solution.hs ">map all q-id's and capitals to countries of the world</a>. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5Ja15PINxpg_vOHgoTXqoxnv_rTj_yGMw2Cgv_vtBiJCKk6nlJ9hKFh3LLVIJFB6C9JnBfo2CjXKcM0DmCgTeXiHvUk9utnlxh-PwO9zx4dLo8nMwZgQzh7KTAHictJHIuAZIGKkVUA9H/s613/02-brussels-and-sprouts.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="512" data-original-width="613" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5Ja15PINxpg_vOHgoTXqoxnv_rTj_yGMw2Cgv_vtBiJCKk6nlJ9hKFh3LLVIJFB6C9JnBfo2CjXKcM0DmCgTeXiHvUk9utnlxh-PwO9zx4dLo8nMwZgQzh7KTAHictJHIuAZIGKkVUA9H/s320/02-brussels-and-sprouts.png" width="320" /></a></div><br /></li><li>2020-11-13: Today's #haskell problem? We convert our alliances and airbases graph into XML (specifically, KML). Why? you ask? BECAUSE WE CAN! ... and to get ready for ... this: #<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D13/Exercise.hs">geodesicmapping</a> Today's #haskell solution is our <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D13/Solution.hs">first two folders in KML</a>. I'M SO PROUD OF YOU! ... hey! I can see my house from here! <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimYmkA8xH1pJBu9lPMLq_14qeuxrLUKOOHy4pgBOigxzl5yZRNMOc1sYvsVvC7-__QuPlrgS_-jL7yMsHBEgrZMNJvn2qPHoynMQQ49shidif_SWVUGE3eHcJalCy03NBTquSXg9URIyzL/s1290/Sint-Truiden-Airbase-Belgium.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="736" data-original-width="1290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimYmkA8xH1pJBu9lPMLq_14qeuxrLUKOOHy4pgBOigxzl5yZRNMOc1sYvsVvC7-__QuPlrgS_-jL7yMsHBEgrZMNJvn2qPHoynMQQ49shidif_SWVUGE3eHcJalCy03NBTquSXg9URIyzL/s320/Sint-Truiden-Airbase-Belgium.png" width="320" /></a> <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizSe4pbnevwnp_AMX_3mEZ6jTg_9SVx7ihyphenhyphen_an5Ru3YfNUEu5tnE3K6McdonDgxRqzvCY4GjYSAloigvJ-7KcX5pcAXafeVPo81yKRhe_5VnfI3Z61yTxVf34T33lEg7A7tA4wD2zm-Tcw/s1288/first-folders.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="586" data-original-width="1288" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizSe4pbnevwnp_AMX_3mEZ6jTg_9SVx7ihyphenhyphen_an5Ru3YfNUEu5tnE3K6McdonDgxRqzvCY4GjYSAloigvJ-7KcX5pcAXafeVPo81yKRhe_5VnfI3Z61yTxVf34T33lEg7A7tA4wD2zm-Tcw/s320/first-folders.png" width="320" /></a></div><br /></div><br /></li><li>2020-11-12: How big is our unicode-... dare I call it a 'problem'? It's not a 'problem,' but it's stopping us from talking with the REST endpoint successfully. So, today's #haskell problem is: how many <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D12/Exercise.hs">non-ASCII unicode points</a> do we have in our Alliances? You want alliances-as-a-graph? You got <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D12/Solution.hs">alliances-as-a-graph</a>! <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-h9dguWSBZwbaM2_sAz-_mHVpXc7yS0ldIRU-6z4lrrm_qgCOTWjDq2z_bHJyUsZ21GxiJX1MTyl8lcu8OIEZvXPu2n-e0zZtjtqvUx5rT9HXWBV33oyvxqVALoVoCqXHq6Ut5SQZOdBE/s789/alliances-air-powers.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="779" data-original-width="789" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-h9dguWSBZwbaM2_sAz-_mHVpXc7yS0ldIRU-6z4lrrm_qgCOTWjDq2z_bHJyUsZ21GxiJX1MTyl8lcu8OIEZvXPu2n-e0zZtjtqvUx5rT9HXWBV33oyvxqVALoVoCqXHq6Ut5SQZOdBE/s320/alliances-air-powers.png" width="320" /></a></div><br /></li><li>2020-11-11: For today's #haskell problem we attempt to upload our alliances to our Continent/Country/Airbase graph. HOW WILL THIS ATTEMPT <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D11/Exercise.hs ">TURN't OUT</a>? The suspense. It's killing me. IT TURN't OUT BAD! IT TURN't OUT BAD! <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D11/Solution.hs">Bad unicode</a>! Bad! le sigh. Today's #haskell solution (which was for yesterday's problem) leads to tomorrow's (today's, actually) Haskell problem. So it goes. </li><li>2020-11-10: The BIG KAHUNA: the military alliances of the world, derived from both wikidata and wikitext. Bringing it all together with the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D10/Exercise.hs">Organization of American States</a> is today's #haskell problem. #BigKahuna Today's #haskell solution: and here we ... [wait for it] ... <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D10/Solution.hs">go</a>! </li><li>2020-11-09: In today's #haskell exercise, we add the United Nations to the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D09/Exercise.hs">AllianceMap</a>. Today's #haskell solution adds the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D09/Exercise.hs">United Nations</a> to the map of world military alliances. </li><li>2020-11-06: For today's #haskell problem we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D06/Exercise.hs">add the European Union</a> to the list of military alliances. Today's #haskell solution: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D06/Solution.hs">European Union</a> from wikidata.org JSON, GET! </li><li>2020-11-05: Today's #haskell problem: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D05/Exercise.hs">rolling in missing alliances and aliases</a> (and implementing alias-parsing). <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D05/Solution.hs">42</a>. That's the number of alliances today's #haskell solution collected from wikitext. Coincidence? I THINK NOT! #DeepThought </li><li>2020-11-04: "We have work to do!" el geophf declares. And so, the #haskell work: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D04/Exercise.hs">missing alliances</a>. <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D04/Solution.hs">The good news is that there's bad news</a>: today's #haskell solution shows that we've missed 35 alliances in our parsing. </li><li>2020-11-03: Today's #haskell problem: I give you a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D03/Exercise.hs">new, funky parser</a> for new, funky alliances! ... and who was it who said that Haskell is no fun? We <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M11/D03/Solution.hs">refine our parsed results</a>, by hand-parsing missed results for today's #haskell solution. </li></ul><p></p>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-33977458366922781652020-10-21T15:25:00.007-07:002020-10-21T19:55:24.532-07:00October 2020 Haskell 1-Liners <ul style="text-align: left;">
<li>2020-10-21: Curry `key` from<br /><code>secondPassFilter :: Ord a => a -> Set a -> Maybe b<br />secondPassFilter key = spf key . Set.lookupGE key</code><br />Given <code>spf :: a -> Maybe a -> Maybe b</code></li><li>2020-10-21: given: <code>updater :: b -> Maybe b</code>
<br />and <code>firstPass :: Ord a => Map a b -> Map a b</code>
<br /><code>firstPass m = foldr (Map.update updater) m (Map.keys m)</code>
<br />#Curry away `m` from the firstPass-function</li>
<ul><li>Social Justice Cleric @noaheasterly<br /><code>firstPass = foldr (Map.update updater) <*> Map.keys</code></li></ul>
<li>2020-10-20: <code>all (\c -> any (`isPrefixOf` c) setb) notinb</code>
<br />#Curry away the `c` lambda argument.</li>
</ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-35772179395530845612020-10-09T10:08:00.023-07:002020-11-03T09:27:41.021-08:00October 2020 1HaskellADay Problems and Solutions<ul>
<li>2020-10-30: Today's #haskell problem is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D30/Exercise.hs">to read and to parse a wikitext</a> file to get a comprehensive list of military alliances. Parsing wikitext of <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D30/Solution.hs">alliances of the world</a>... WITH #haskell! </li><li>2020-10-28: Today's #haskell problem is to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D28/Exercise.hs">ingest military alliances of the world</a> from <a href="http://wikidata.org">http://wikidata.org</a> as JSON. The #haskell solution: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D28/Solution.hs">(*:)-operator and a higher-order alter-function FTW</a>! </li><li>2020-10-26: The previous week we've examined wikidata for countries, continents and airbases. For today's #haskell exercise, let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D26/Exercise.hs">memorialize our findings</a>.* 'memorialize our findings' is a fancy-pants term for 'print statement,' ICYMI. For the #haskell solution, "We are now going to introduce some steps that are <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D26/Solution.hs">a bit more difficult</a>... Ready. Set. And. Begin." <div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/LmApDbvNCXg" width="320" youtube-src-id="LmApDbvNCXg"></iframe></div><br /></li><li>2020-10-23: Today's #haskell problem: "<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D23/Exercise.hs">Unicode? What, even, is that?</a>" ... sez Haskell, smh. Also, if you know how to get Text not to escape unicode points on output (to, say, a REST endpoint), much obliged if you told me this dark magic. Today's #haskell solution shows <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D23/Solution.hs">airbases (with their associated countries) added to the graph database</a>. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4Mnpyh0NcVaXxb4RHUBtpvVD9UfOHndJUWVAKaLKRkKGKejusPsDH935Mbi2CviIvXUr_bdcbKLAe6xcLsAgZnUnaVl8Ct4-QShiGM76p1sVVaT8XJPtX3z-qSvTdIROIQ3z1Qv82WLhq/s949/airbases.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="775" data-original-width="949" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4Mnpyh0NcVaXxb4RHUBtpvVD9UfOHndJUWVAKaLKRkKGKejusPsDH935Mbi2CviIvXUr_bdcbKLAe6xcLsAgZnUnaVl8Ct4-QShiGM76p1sVVaT8XJPtX3z-qSvTdIROIQ3z1Qv82WLhq/s320/airbases.png" width="320" /></a></div><br /></li><li>2020-10-20: Next evolutionary step. We have Continents and countries as data structures. For today's #haskell problem let's find out <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D20/Exercise.hs">how we can (can't?) merge in airbases with countries</a>. <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D20/Solution.hs">Hoo, doggies!</a> "Upload airbases to the graph database!" he said. "It'll be easy!" he said. Today's #haskell solution, if not in book-form, then in book-length! </li><li>2020-10-16: Map of a -> b or b -> a? ... If you're asking that question, why not <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D16/Exercise.hs">Graph</a>? Today's #haskell exercise. A <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D16/Solution.hs">mapping of continents to countries</a>. Surprisingly, <a href="http://wikidata.org">wikidata.org</a> does not have this as data amenable to extraction. <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeD42LHkvkLlD6BiUyCqrs9F6eWx_bFi0_L2nEhhyphenhyphenYBBygzil9xOY6IYVggJCpPGTalgfrb_Lr-rdsuj3t4-SoehwZUzouOsPrPkxMwQ4-Yjc3rdFLRJsPuQL3PgseMLAeK5F2soAvt47y/s734/continents-countries.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="583" data-original-width="734" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeD42LHkvkLlD6BiUyCqrs9F6eWx_bFi0_L2nEhhyphenhyphenYBBygzil9xOY6IYVggJCpPGTalgfrb_Lr-rdsuj3t4-SoehwZUzouOsPrPkxMwQ4-Yjc3rdFLRJsPuQL3PgseMLAeK5F2soAvt47y/s320/continents-countries.png" width="320" /></a></div><br /></li><li>2020-10-15: From continent->country mapping to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D15/Exercise.hs">country->continent</a> mapping for today's #haskell problem. <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D15/Solution.hs">`sequence` is the secret-sauce</a> for today's #haskell solution. </li><li>2020-10-14: Today's #haskell problem is to get <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D14/Exercise.hs">countries by continent</a> from a ... 'markdown' file? That is not markdown. Deal with it. Countries: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D14/Solution.hs">meet</a> your Continents. </li><li>2020-10-13: Okay. #StringsAreWrong. Everybody knows this. Wikidata: "Let's encode LongLats as strings ... IN JSON!" <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D13/Exercise.hs">Please let's not</a>. Today's #haskell exercise. The solution that produces airbases with lat/longs. <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D13/Solution.hs">REAL lat/longs</a>, smh. </li><li>2020-10-12: Today's #haskell problem is <a href="Today's #haskell problem is airbases of the world from wikidata.org ... with some duplicates. https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D12/Exercise.hs">airbases of the world</a> from <a href="http://wikidata.org">wikidata.org</a> ... with some duplicates. Today's #haskell solution <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D12/Solution.hs">reads in JSON</a>, even ... 'JSON' that encodes 'LongLat's (not lat/longs) as ... strings? Really? Yes, even points-as-strings. Remember: #<a href="https://dtai.cs.kuleuven.be/projects/ALP/newsletter/archive_93_96/net/strings/strings.html">StringsAreWrong</a> ~ Richard A. O'Keefe, 26 April 1994 </li><li>2020-10-09: Today's #haskell problem is this: Production data: "Let's see if we can make the simple act of parsing a 'JSON file' [<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M10/D09/Exercise.hs">that isn't a JSON file</a>] impossible for the ol' el geophf!" Nice try, production data. Nice try. </li>
</ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-68676334277614232362020-09-02T14:41:00.006-07:002020-09-11T10:49:20.846-07:00September 2020 Haskell Problems and Solutions<ul style="text-align: left;">
<li>2020-09-09: Today's #haskell exercise is to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M09/D09/Exercise.hs">compile our book-word-net</a> into a Haskell module. The #haskell solution <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M09/D09/Solution.hs" target="_blank">compiled the August 2020 Gutenberg top 100 read books</a> into Haskell terms. </li><li>2020-09-08: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M09/D08/Exercise.hs">Data analytics</a> on our top 100 gutenberg books is today's #haskell exercise. Did you know that there approximately 2000 English words in common usage? Today's #haskell solution: "Sounds <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M09/D08/Solution.hs">about right</a>."</li>
<li>2020-09-01: Today's #haskell problem is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M09/D01/Exercise.hs">reducing a map of mapping of information to maps to a map</a>. HOW HASKELL-Y! Yesterday's #haskell solution updated both problem and solution and made some <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M09/D01/Solution.hs">data-discoveries along the way</a>. Neat-o! </li></ul><p></p>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com1tag:blogger.com,1999:blog-4650294074444534066.post-45088254300876643842020-09-01T11:17:00.000-07:002020-09-01T11:17:11.319-07:00February 2019 Haskell 1-liners<p> </p><ul style="line-height: 18px; margin: 0.5em 0px; padding: 0px 2.5em;"><li>February 18th, 2019:<br />Define ext :: (Maybe a, b) -> Maybe (a,b)<br />e.g.: ext (Just 5, "Hi") = Just (5, "Hi")</li><ul><li>Al͜l ̸͑ha͂͟il̶! @TechnoEmpress \o/ <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzd_y-NlDNlYniGzGHIL6fVYhs6dMQn9tmLOGmQX_jkOvOzjrGwaqlqL4WZ5r6mbRU-Yz1287yGCPtVrdCrQ1iq3u8jgDg0-MY-kMPfhUo14ewLTty7n97RxOD9SkPnRoIFzmXMZ1tHCDo/s1600/ext.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="562" data-original-width="1199" height="149" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzd_y-NlDNlYniGzGHIL6fVYhs6dMQn9tmLOGmQX_jkOvOzjrGwaqlqL4WZ5r6mbRU-Yz1287yGCPtVrdCrQ1iq3u8jgDg0-MY-kMPfhUo14ewLTty7n97RxOD9SkPnRoIFzmXMZ1tHCDo/s320/ext.jpg" width="320" /></a></div></li><li>cλementd @clementd `fmap swap. sequenceA . swap` :-)</li><li>Raveline @Raveline bisequence . second pure</li><li>Alexey Radkov @sheshanaag uncurry (flip $ fmap . flip (,))</li><li>a fool @fresheyeball ext = \case (Just x, y) -> Just (x, y); _ -> Nothing</li></ul></ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com1tag:blogger.com,1999:blog-4650294074444534066.post-57343993704102768142020-09-01T09:41:00.004-07:002020-09-08T11:14:36.667-07:00September 2020 Haskell 1-liners<ul>
<li><p>2020-09-08: given</p>
<pre>
removeInfreqs :: Set String -> Ontology -> Ontology
removeInfreqs infrequentWords ont =
Map.map (\wordcounts -> foldl (flip ri') wordcounts infrequentWords) ont</pre>
<p>where <code>Ontology</code> is a map-of-maps.</p>
<ol>
<li>remove <code>flip</code> to get the same functional result.</li>
<li>curry away <code>ont</code> from the function <code>removeInfreqs</code></li>
<li>curry away <code>wordcounts</code> from the map-lambda function.</li>
<li><p>curry away <code>infrequentWords</code> from the function <code>removeInfreqs</code></p>
<p>n.b.: This curry may not be as straightforward as the other curries.</p></li>
</ol>
</li>
<li><p>2020-09-01: Given all of the above, and now that you've curried the above lambda to [SPOILER]:</p>
<p><code>\key -> const (not (Set.member key stoppers))</code></p>
Curry away <code>key</code> from this new lambda.</li>
</ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-27762468573436546372020-08-26T16:00:00.026-07:002020-08-31T14:22:20.180-07:00August 2020 1HaskellADay 1Liners<ul style="text-align: left;"><li>2020-08-31:
<p>
</p>#Haskell #BetterWithCurry #1Liner For:
<pre>
>>> :t Map.filterWithKey
Map.filterWithKey :: (k -> a -> Bool) -> Map k a -> Map k a</pre>
<p>we have this filtering function: <code>\key _val -> not (Set.member key stoppers)</code></p>
<p><code>_val</code> is unused. Curry it away.</p>
</li>
<li>2020-08-28:
<blockquote><code>rmFront :: Set Char -> String -> String<div>rmFront weirds str = dropWhile (flip Set.member weirds) str</div></code></blockquote><div>Simple currying questions: can this function-implementation be simplified with currying? Can it be simplified ... MORE? Answers: yes, and yes. Show your implementation.</div><div><br /></div></li>
<li>2020-08-26: We have this: <code>\info -> importBook info >>= return . (info,)</code> There are way too many <code>info</code>-references. What's a better way to write this expression?</li><ul><li>Five solutions from <a href="https://twitter.com/noaheasterly">@noaheasterly</a>:</li><ul><li>runKleisli (id &&& Kleisli importBook)</li><li>liftA2 (liftA2 (,)) return importBook</li><li>liftA2 (fmap . (,)) id importBook</li><li>traverse importBook . join (,)</li><li>traverse importBook . (id &&& id)</li></ul><p style="text-align: left;"></p></ul></ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0tag:blogger.com,1999:blog-4650294074444534066.post-4507936755495767092020-08-03T11:24:00.020-07:002020-09-01T13:22:50.488-07:00August 2020 1HaskellADay Problems and Solutions<ul style="text-align: left;"><li>2020-08-31: For today's #haskell problem we learn the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D31/Exercise.hs">nature of the words</a> "the" and "yesterday." Fundamental things. <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D31/Solution.hs ">SCROOGE</a>! Yesterday's #haskell solution shows us that "scrooge" was the most-written word in "A Christmas Carol." Fancy that! </li><li>2020-08-28: Today's #haskell problem: a word-frequency analysis, ... a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D28/Exercise.hs">CLEAN-word-frequency analysis</a>. Today's #haskell solution. Amazing, isn't it, that the word Charles Dickens wrote the most, by far, was '<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D28/Solution.hs">the</a>'. #writerslife </li><li>2020-08-27: We're looking at <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D27/Exercise.hs">'weird characters' and 'weird words'</a> for today's #haskell problem. We found words, weird words, and the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D27/Solution.hs">weird characters in those weird words</a> in today's #haskell solution. </li><li>2020-08-26: For today's #haskell problem, <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D26/Exercise.hs">let's download the top-100 books</a> from project gutenberg! For today's #haskell solution, we have the top-100 gutenberg books, <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D26/Solution.hs">downloaded and ready for analysis</a>! </li><li>2020-08-25: "<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D25/Exercise.hs">Project Gutenberg, here I come!</a>" is my battle-cry for today's #Haskell problem. We have <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D25/Solution.hs">an index to book indices</a> for yesterday's #haskell solution. </li><li>2020-08-24: Multiplication using cosines is called ... <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D24/Exercise.hs ">Prosthaphaeresis</a>... and also called: "today's #haskell problem." <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjriM7ryqfrdC1reOvKYK2YfSwdDKbQS6ip3OUaZqVT2MwuHoab8lgjBXi8fzm7GAaYz2S13welNlx1c4fLoTW2dsa4f9EZAmQ0TUBXXsFMOHDciOBU88F0vgr4OrusUyqtTU-sLb0TJlRv/s1200/cosine-product.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="651" data-original-width="1200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjriM7ryqfrdC1reOvKYK2YfSwdDKbQS6ip3OUaZqVT2MwuHoab8lgjBXi8fzm7GAaYz2S13welNlx1c4fLoTW2dsa4f9EZAmQ0TUBXXsFMOHDciOBU88F0vgr4OrusUyqtTU-sLb0TJlRv/s640/cosine-product.jpg" width="640" /></a></div></li><li>2020-08-21: Gimme a hint? ... or two? Today's #haskell problem is to find words in dictionaries with the help of <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D21/Exercise.hs">supplied hints</a>. "Alien." <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D21/Solution.hs">The word was "alien"</a> for today's #Haskell solution (because it's always the aliens) (I didn't say that.) I, FOR ONE, WELCOME OUR NEW ALIEN OVERLORDS! </li><li>2020-08-20: Yesterday we did word-lookups from provided dictionaries. Today's #haskell problem is a little analysis (a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D20/Exercise.hs">word histogram</a>) of those word-dictionaries. <br />"fromList [(1,234371)]" That, there, <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D20/Solution.hs">them's alotta words</a>, yup. Yesterday's #haskell solution. </li><li>2020-08-19: <a href="http://SKRIBBL.io">SKRIBBL.io</a>! (A part of) <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D19/Exercise.hs">SKRIBBL.io</a> is the #Haskell challenge for today. And the #haskell solution, <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D19/Solution.hs">monad-style</a>! </li><li>2020-08-10: HEAPS! Luv me sum HEAPS! Today's #haskell problem is to define the <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D10/Exercise.hs">Heap collection and its operations</a>. </li><li>2020-08-03: Today's #haskell problem is to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D03/Exercise.hs">generate random permutation</a> of active team members. So, yeah: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M08/D03/Solution.hs">random permutes</a> down low on the team members, d'#Haskell </li></ul>geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com2tag:blogger.com,1999:blog-4650294074444534066.post-26791978848477532042020-07-02T07:41:00.005-07:002020-07-31T20:11:15.254-07:00July 2020 1HaskellADay Problems and Solutions<br />
<ul>
<li>2020-07-31: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D31/Exercise.hs">Well, that's random</a>. Generating random numbers and sequences is today's #Haskell problem. Today's #haskell solution shows that <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D31/Solution.hs">I can (<*>) that monad, first go</a>, without even looking it up or anything. So, yeah, I'm walking pretty tall right now. </li><li>2020-07-30: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D30/Exercise.hs">Kate and Shoaib are going on vacation</a>. Commander Adama in Star Wars tells us that for today's #haskell problem, we are to "Make it so, Number one." And: there they go! Shoaib and Kate, <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D30/Solution.hs">going on a vacay, havin' fun, and type-safely, at that</a>, because of the #haskell solution 'n stuff. </li><li>2020-07-29: "How many days until ...?" A <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D29/Exercise.hs">date calculator</a> for today's #haskell problem. When I say: "Compute the date," <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D29/Solution.hs">I'm not talking fig trees, here</a>. The solution to today's #Haskell problem. <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3qMHtj14S2kus_-WT4ggjlE2DQg6VUhUW3egomoJ0ui9jyPWGAQ_7d5v1VUoBe2MiIF_kyVPUbWMG6T1ZCUZG0Vgw__IPmxAwhjv9QgQ6znbO5zvZj433il1bIB8z53IsE4eM9NNKGr43/s1600/calendar2_orig.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="600" data-original-width="600" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3qMHtj14S2kus_-WT4ggjlE2DQg6VUhUW3egomoJ0ui9jyPWGAQ_7d5v1VUoBe2MiIF_kyVPUbWMG6T1ZCUZG0Vgw__IPmxAwhjv9QgQ6znbO5zvZj433il1bIB8z53IsE4eM9NNKGr43/s320/calendar2_orig.jpg" width="320" /></a></div>
</li>
<li>2020-07-28: Today's #haskell problem involves<a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D28/Exercise.hs"> passing arguments to and verifying results from an external application</a>. 'frankenfurters.' That's what we're trying to sum here. <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D28/Solution.hs">'frankenfurters.' 'Fault Tolerance'? We've got that</a> with today's #haskell solution. </li>
<li>2020-07-27: Today's #Haskell exercise makes us realize that ... "All, in all, you're just a ... nother brick in <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D27/Exercise.hs">THE WALL</a>. :/" <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D27/Solution.hs">A solution</a> pour vous, s'il vous plaît. <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjESLg7QVXEvL8Wv_3PWOJWJfQ4ajhB5FN4ny-fJK4I5Ww-GNtrXe8B8Kn3E-eodtBzCuhDl41x2_Xws_-rpv24FX_WNNx_-phOtLv8Lvc-HPx4x_bySkWNJu8Y8vUq0IwX4wBS8O_NL-26/s1600/the-wall.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="176" data-original-width="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjESLg7QVXEvL8Wv_3PWOJWJfQ4ajhB5FN4ny-fJK4I5Ww-GNtrXe8B8Kn3E-eodtBzCuhDl41x2_Xws_-rpv24FX_WNNx_-phOtLv8Lvc-HPx4x_bySkWNJu8Y8vUq0IwX4wBS8O_NL-26/s1600/the-wall.jpg" /></a></div>
</li>
<li>2020-07-24: Today's #haskell problem <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D24/Exercise.hs">explores the result of processed images</a> from, in this case, Amazon's Rekognition. Today's #haskell solution: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D24/Solution.hs">BIRDz! ... Cardinals, in fact</a>. <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAKG7TfDbYls6xkOa3I44mjGFEYOPYq4MVJxfwUklGEa-UbETybmUjYDIkGATXK_KzeO9sFUEvibuP8ITYufhn82rU4iCrpA1Rwa6_V-HgQQtO1R_UU8vZEwZIH00q5d7gCeUUisq6GwLf/s1600/cardinals-amazon-rekognition.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="657" data-original-width="479" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAKG7TfDbYls6xkOa3I44mjGFEYOPYq4MVJxfwUklGEa-UbETybmUjYDIkGATXK_KzeO9sFUEvibuP8ITYufhn82rU4iCrpA1Rwa6_V-HgQQtO1R_UU8vZEwZIH00q5d7gCeUUisq6GwLf/s320/cardinals-amazon-rekognition.png" width="233" /></a></div>
</li>
<li>2020-07-23: For today's #haskell problem, let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D23/Exercise.hs">read in a JPG</a> (o' FLAH'z!) and write it out as a TIFF ... for, you know, like: an image processing/classification exercise, at some later date. Ooh! TIFFY! <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D23/Solution.hs">TIFF saved from loaded JPEG image</a>. <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRKp-57GpFcWWVW-O3_s59yEX3blmi89d6btlpOHXpx9mSMrL_xkG-EqUR6bAcwqq6-f8U6m_Q1KmFHGo3HxCh878vcXXeXJCWK4dK8aJmb_JjeQO7QSFS4ih7XZF9EwCz0AwF3AbBRART/s1600/echinacea.jpeg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1200" data-original-width="1600" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRKp-57GpFcWWVW-O3_s59yEX3blmi89d6btlpOHXpx9mSMrL_xkG-EqUR6bAcwqq6-f8U6m_Q1KmFHGo3HxCh878vcXXeXJCWK4dK8aJmb_JjeQO7QSFS4ih7XZF9EwCz0AwF3AbBRART/s320/echinacea.jpeg" width="320" /></a></div>
</li>
<li>2020-07-22: For today's #haskell problem we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D22/Exercise.hs">extract data from JSON</a> returned from a REST endpoint. The #haskell solution is <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D22/Solution.hs">declarative/functional-composition goodness</a> to parse data from JSON returned from a REST endpoint. </li>
<li>2020-07-21: We <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D21/Exercise.hs">ping a public API REST endpoint</a> for today's #Haskell problem. For today's #haskell solution, <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D21/Solution.hs">simpleHttp in Network.HTTP.Conduit</a> does the trick! </li>
<li>2020-07-20: For today's #haskell problem we read a file that contains a <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D20/Exercise.hs">JSON message</a> and parse it. </li>
<li>2020-07-17: Oops! <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D17/Exercise.hs">Where has the time gone?</a> That's today's ... I mean, YESTERDAY's, #haskell problem. <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoPI23F-vpOqMIpZENW4wZwBuD7iBS-U8QjvwHO6gOQmAC2HnDuMYcoNUN6hlq5LpxnI662s-kRCRRpUNRTKpt3ut97CKlkmTz5hz4ieutw1UQA0WMMkw_hObctpMUhm5I0miOyRRHFrV1/s1600/slow-clock.jpeg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="1200" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoPI23F-vpOqMIpZENW4wZwBuD7iBS-U8QjvwHO6gOQmAC2HnDuMYcoNUN6hlq5LpxnI662s-kRCRRpUNRTKpt3ut97CKlkmTz5hz4ieutw1UQA0WMMkw_hObctpMUhm5I0miOyRRHFrV1/s320/slow-clock.jpeg" width="240" /></a></div>
</li>
<li>2020-07-16: And now, for something completely different: today's #haskell problem has us <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D16/Exercise.hs">reading a file, parsing the data, and ranking the results</a>. #haskell solution to <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D16/Solution.hs">which level is most recruit-efficient</a> for a dark chest. </li>
<li>2020-07-15: For today's #haskell problem, we pull what we've done so far all together and <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D15/Exercise.hs">compute today's pairings, given historical context</a>. </li>
<li>2020-07-14: For today's #haskell problem, we pull what we've done so far all together and <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D15/Exercise.hs">compute today's pairings, given historical context</a>. </li>
<li>2020-07-14: For today's #Haskell problem, we look at <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D14/Exercise.hs">using our historical context</a> of pairings to answer questions for future pairings. </li>
<li>2020-07-13: Now that we've selected pairings for today, let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D13/Exercise.hs">store those pairings into an historical context</a> for today's #haskell problem. </li>
<li>2020-07-08: <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D08/Exercise.hs">Pairing and ... 'Mobbing'</a> (?) ... okay, really??? is our game for today's #haskell problem. A <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D08/Solution.hs">solution</a> to the simple pairing-problem.</li>
<li>2020-07-07: For today's #haskell problem, we lay a foundation for building a team-pairing app. This day's problem <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D07/Exercise.hs">addresses a History-type</a> to provide context to the pairing-algorithm. </li>
<li>2020-07-06: For today's #haskell problem, we look at finding the <a href="https://github.com/geophf/1HaskellADay/tree/master/exercises/HAD/Y2020/M07/D06">spanning trees of a graph</a>. <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJ9HgUx9Q-pmAAXItNcPaNPQNqBN60N_U4gxtYd6qAZevRTonkHVTSE6y3k0zJYoEQAp55CFyOh5SCuZZg3LDU3EXS1NxG3gwtdzbZfNJlZJb2SFIdjFZA78TsAgSFrcgTSORfpeXRYksC/s1600/spanning-tree.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="220" data-original-width="220" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJ9HgUx9Q-pmAAXItNcPaNPQNqBN60N_U4gxtYd6qAZevRTonkHVTSE6y3k0zJYoEQAp55CFyOh5SCuZZg3LDU3EXS1NxG3gwtdzbZfNJlZJb2SFIdjFZA78TsAgSFrcgTSORfpeXRYksC/s1600/spanning-tree.png" /></a></div>
</li>
<li>2020-07-02: Today's #haskell exercise finds us (acyclic) <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D01/Exercise.hs">pathing</a> though a simpler, yet-not-fully connected, graph. <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7m7hiAJT6DV4PJUytN-FpU7t8rfHIv2VxgEnyIuXMWT5s8JzGEDvsTEJm8tFiDWpG5kTq6ujprmSpmUUQcfZhgK4y2B6NdPCc308w8Ew2Drd1AqtiOnpeBPOi2kwne0H38gQ_TmBeI0Lm/s1600/graph2.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="174" data-original-width="123" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7m7hiAJT6DV4PJUytN-FpU7t8rfHIv2VxgEnyIuXMWT5s8JzGEDvsTEJm8tFiDWpG5kTq6ujprmSpmUUQcfZhgK4y2B6NdPCc308w8Ew2Drd1AqtiOnpeBPOi2kwne0H38gQ_TmBeI0Lm/s1600/graph2.gif" /></a></div>
</li>
<li>2020-07-01: For today's #haskell problem we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M07/D02/Exercise.hs">find cycles in graphs</a>, ... MOTORcycles in graphs! AHA! AND MAKE MINE A DUCATI! ON FYE-YARRRR! 🔥 ... no ... wait ... Oh, well. #GraphTheory <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0C8GBhXKydQ8KOWX1tAEpMRhkft0IQW8RuW5Z1Fxaw3dnsmBWx4Owlkrc0Hz-T9AZPNDKPZvhecPY5ZMog7ufPvVuyWhuLQdJFAfOn1fZkGcIf5MGdiJnNhwUtunH1RYR_cxaykUOzicM/s1600/2018-Ducati-Panigale-V4-caught-fire-Canada_1.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="675" data-original-width="1200" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0C8GBhXKydQ8KOWX1tAEpMRhkft0IQW8RuW5Z1Fxaw3dnsmBWx4Owlkrc0Hz-T9AZPNDKPZvhecPY5ZMog7ufPvVuyWhuLQdJFAfOn1fZkGcIf5MGdiJnNhwUtunH1RYR_cxaykUOzicM/s320/2018-Ducati-Panigale-V4-caught-fire-Canada_1.jpg" width="320" /></a></div>
</li>
</ul>
geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com1tag:blogger.com,1999:blog-4650294074444534066.post-53478682578649947832020-07-02T07:38:00.000-07:002020-07-02T07:38:11.709-07:00June 2020 1HaskellADay Problems and Solutions<li>YAY! HELLO! Our first #haskell exercise in a while!... and this exercise is about ... wait for it ... <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M06/D29/Exercise.hs">exercise</a>! <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI7C9BzaX0jbux2aJWkKor2nD5pu6LiHVAWsZU5gsI_Jgtj9HHikTxy5AO7stUE9cf-SinIEnLV9bCepdjhNE7gowXx7Jn1rRY0ie_IrersgB5CFoBuAsOc39WYmVRBp4F_mbGG2DeqzpQ/s1600/steps.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="535" data-original-width="692" height="247" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI7C9BzaX0jbux2aJWkKor2nD5pu6LiHVAWsZU5gsI_Jgtj9HHikTxy5AO7stUE9cf-SinIEnLV9bCepdjhNE7gowXx7Jn1rRY0ie_IrersgB5CFoBuAsOc39WYmVRBp4F_mbGG2DeqzpQ/s320/steps.png" width="320" /></a></div>
</li>
<li>For today's #haskell exercise we <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2020/M06/D30/Exercise.hs">convert a set of arcs to a graph</a>. #GraphTheory <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmUuzzLQj8DtS7cDkDaal3IDpfLxGn7eZXZdl3pBdDF1RNL40hGcLVOlOL8oxJZRvWpZYqjamzVrA4LiqfSATG_s-IcUTo9xzfwmiRjk9D4x2xX7QncAg10Ovaw4TA66mNlWhF07Cpv91J/s1600/graph.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="739" data-original-width="444" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmUuzzLQj8DtS7cDkDaal3IDpfLxGn7eZXZdl3pBdDF1RNL40hGcLVOlOL8oxJZRvWpZYqjamzVrA4LiqfSATG_s-IcUTo9xzfwmiRjk9D4x2xX7QncAg10Ovaw4TA66mNlWhF07Cpv91J/s320/graph.png" width="192" /></a></div>
</li>
geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com1tag:blogger.com,1999:blog-4650294074444534066.post-19081626058943831972019-10-17T11:09:00.002-07:002019-10-17T11:09:28.002-07:00February 2019 1HaskellADay Problems and Solutions<ul style="caret-color: rgb(51, 51, 51); color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.4; list-style-image: initial; list-style-position: initial; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;">February 20th, 2019: Wednesday's #haskell problem: we've got words, now let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2019/M02/D20/Exercise.hs" style="color: #7d181e; text-decoration: none;">find words that start with</a> ... 'x'. </li>
<li style="border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;">February 19th, 2019: Tuesday's #haskell problem: now that we have a word finder, let's <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2019/M02/D19/Exercise.hs" style="color: #7d181e; text-decoration: none;">pretty-print the results</a>! </li>
<li style="border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;">February 18th, 2019: Monday's #haskell problem is to come up with <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2019/M02/D18/Exercise.hs" style="color: #7d181e; text-decoration: none;">sets of words</a>using only a set of supplied letters. Monday's #haskell solution has some <a href="https://github.com/geophf/1HaskellADay/blob/master/exercises/HAD/Y2019/M02/D18/Solution.hs" style="color: #7d181e; text-decoration: none;">trickiness around empty sets</a>: this, we call 'fun.' </li>
</ul>
geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com2tag:blogger.com,1999:blog-4650294074444534066.post-34390846015321772442019-02-18T00:52:00.001-08:002019-02-18T00:52:07.513-08:00April/May 2019 1HaskellADay 1Liners<ul style="line-height: 18px; margin: 0.5em 0px; padding: 0px 2.5em;">
<li>May 27th, 2018:<br />data F = F { a, b, c :: String }<br />data Stamped a = { time :: Day, stamped :: a }<br /><br />f :: Stamped F -> String<br /><br />output of f x is "time a b c" for the respective values of time, a, b, c<br /><br />Is there some monadic / applicative elegant definition that does this?</li>
<ul>
<li>Nickolay Kudasov @crazy_fizruk<br />f = intercalate “ “ . sequence [ show.time, a.stamped, b.stamped, c.stamped ]</li>
<li>Nickolay Kudasov @crazy_fizruk<br />f = intercalate " " <$> http://pure.show .time <> (sequence [a, b, c]).stamped<br />A bit trickier, but shorter and uses stamped once.</li>
</ul>
<li>April 13th, 2018: given f :: [a] -> b -> [c]<br />where c is a derived from g :: a -> b -> c<br /><br />You have [a] and [b]<br /><br />Write a function h :: [a] -> [b] -> [c] from f</li>
</ul>
geophfhttp://www.blogger.com/profile/09936874508556500234noreply@blogger.com0