- September 15th, 2016:

Given [1..n], create an infinite list of lists [[1.. n], [n+1 ... n+n], [n+n+1 ... 3n], ...]

counting :: [Integer] -> [[Integer]] - joomy @cattheory

counting = (map . (+) . fromIntegral . length) >>= iterate - September 30th, 2016: The reverse of August's one-liner:

f :: (Maybe a, b) -> Maybe (a,b)

define f. Snaps for elegance.

# Typed Logic

Incorporates strong typing over predicate logic programming, and, conversely, incorporates predicate logic programming into strongly typed functional languages. The style of predicate logic is from Prolog; the strongly typed functional language is Haskell.

## Saturday, October 22, 2016

### September 2016 1HaskellADay 1Liners Problems and Solutions

## Sunday, October 2, 2016

### September 2016 1HaskellADay problems and solutions

- September 29th, 2016: Today's #haskell exercise looks at ways to get transactions from Merkle tree that DON'T involve a full-tree scan every time (given you do not know the transaction-hash, and you wish to search by user/address) #blockchain. Today's #Haskell solution transforms a Merkle tree of #bitcoin transactions into a MultiMap!
- September 28th, 2016: TOO MANY SINGLE-LEAF NODES! Today's #haskell problem improves the insert algorithm to minimize single-leaf nodes.

- September 27th, 2016: Today's #haskell exercise we discover a path through a Merkle tree to a hashed leaf node (a #blockchain transaction). For the #haskell solution we find #bitcoin transactions in a Merkle tree by hash
- September 26th, 2016: For today's #haskell problem we compare two Merkle Trees, one set the same, another set slightly different. And I hope this #haskell solution doesn't get carried away into Ackermann-territory! Merkle Tree node-difference.

- September 23rd, 2016: Today's #haskell exercise distills #bitcoin transactions, then represents them as relations. Today's #haskell solution views #bitcoin trades as graphs

- September 22nd, 2016: WHOA! WHOA! WHOA! Let's scale back the problem statement a bit, shall we? for today's #haskell exercise. Got the transactions and the addresses from the latestBlock on the #blockchain in #haskell
- September 19th, 2016: Today's #haskell problem we create our own Merkle tree from (faux) #bitcoin transactions and then visualize it! The #haskell solution uses real #bitcoin transactions to populate then visualize a Merkle Tree as a graph structure
- September 16th, 2016: Today's #haskell problem is sort of Sudoku with a BINOCULAR-twist! and what other unique 9-letter words do you know? This solution used generate-then-inline, totally avoiding testing with guards. Much faster AND correct!
- September 15th, 2016: Today's #haskell problem is neither soduko nor magic squares. And our solution was a generate-then-test with guards, can you do better?
- September 14th, 2016: For today's #haskell problem we study 'domino theory' ... eheh.
We took the brute-force approach to solve today's #haskell problem. Do you have a better approach?
- September 12th, 2016: Today's #haskell problem is a logic puzzle of infinities and infinitesimals … Not really, but it has a ring to it!
- September 9th, 2016: For today's #haskell problem with go on a little cryptoarithmetic-romp. And I got to use the word 'romp' in a tweet. A little bit of monadic combine; a little bit of
`sortBy (compare `on` snd)`

and we have our AFTER(SHOCK)ING #haskell solution - September 8th, 2016: Today's #haskell exercise asks you to create a (balanced) Merkle tree from block summaries from the #blockchain. We insert some blocks from the #blockchain to create a (balanced) Merkle tree for today's #haskell solution
- September 6th, 2016: For today's #haskell exercise we read in an entire block (with its transactions) of the #blockchain. You want all the transactions of a blockof the #blockchain? Today's #haskell solution gives them to you
- September 5th, 2016: For today's #haskell problem we begin to deconstruct blocks of the #blockchain by parsing block transactions. FromJSON instance definitions in #haskell allow us to parse transactions of blocks in the #blockchain
- September 2nd, 2016: Today's #haskell problem we look at reading in just one block of the #blockchain. Today's #haskell solution fetches the latest block from the #blockchain thanks to https://blockchain.info
- September 1st, 2016: Today's #haskell exercise gives us a rudimentarily-constructed Merkle Tree. Today's #haskell solution we create leaves and branches of Merkle trees (and a very simple tree sample) #bitcoin

## Thursday, September 15, 2016

### August 2016 1HaskellADay 1Liners

- August 20th, 2016: maybeify :: (a, Maybe b) -> Maybe (a, b)

Define maybeify. Snaps for elegance. - Hardy Jones @st58 sequence
- Bruno @Brun0Cad mapM id
- Thomas D @tthomasdd {-# LANGUAGE TupleSections #-}

mabeify (x,mY) = maybe Nothing (return . (x,)) mY - Андреев Кирилл @nonaem00 import "category-extras" Control.Functor.Strong

maybeify = uncurry strength - bazzargh @bazzargh I can't beat 'sequence', but: uncurry (fmap.(,))
- Nick @crazy_fizruk distribute (from Data.Distributive)

## Thursday, September 1, 2016

### August 2016 1HaskellADay Problems and Solutions

###
**August 2016**

- August 31st, 2016: Today's #haskell problem we prepare Merkle trees (used by #blockchain/#Bitcoin) by hashing data, then hashing hashes. Wow! That was a lot of hash...ing! SHA256 #crypto #Bitcoin #blockchain used for today's #haskell solution
- August 30th, 2016: In today's #haskell exercise we look at #bitcoin mining machines comparing cost, efficiency and potential BTC found. Today's #haskell solution compares #bitcoin mining hardware ... by deriving a theorem of logic. Yeah. So: that.
- August 29th, 2016: For today's #haskell problem we find the next number in a series. Then @JMVarnerBooks asks for an efficient encoding. A little bit of group, a little bit of compress, and we have today's #haskell solution. YES!
- August 26th, 2016: Today's #haskell problem continues with currencies, looking at gold, then comparing #bitcoin

Today's #haskell solution
looks at gold then compares to #bitcoin and generalizes recursion

Today's #haskell solution is worth $180k ... five years ago. I wonder what it will be worth 5 years hence?

Okay! For today's #haskell solution we discover our node and relation types in twitter data-as-graphs JSON!

Okay, we have a #Haskell solution ... finally ... maybe. The solver took too long, so I solved it myself faster :/

## Saturday, August 20, 2016

### 1Liners for July 2016

- July 14th, 2016: So you have x :: [a] in the IO monad, and the function f :: a -> b What is the expression that gets you IO [b]?

## Sunday, July 31, 2016

### July 2016 1HaskellADay Problems and Solutions

###
**July 2016**

- July 28th, 2016: Lao Tzu says what is crooked cannot be made straight... but what does that guy know? Today's #haskell exercise
- July 27th, 2016: For today's #haskell exercise we look at the shortest distance between any two points in a graph. Today's #haskell solution uses brute-force to find shortest distance paths, which works for small graphs
- July 26th, 2016: Today's #haskell exercise looks at (one aspect of) shortest pathing through graphs. Today's #haskell solution is the shortest path through a graph, NOT using continuations. *WHEW*
- July 25th, 2016: For today's #haskell problem we look at pathing through graphs with cycles. We avoid 'teh Sadeness' with today's #haskell solution of pathing graphs with cycles
- July 22nd, 2016: For today's #haskell exercise we tear apart #graph-construction or -pathing ... or both. Today's #haskell solution works PERFECTLY if your graph doesn't have cycles like this one!
- July 21st, 2016: Today's #haskell problem looks at simplifying the representation of pathing through #graph data The #haskell solution paths through a graph, but ... hm: not perfectly. We'll look at complete pathing today.
- July 20th, 2016: Yesterday, I didn't give complete information for the figure. Today's #haskell exercise rectifies that #graph Today's #haskell solution is a #graph of complete information of the figure, and a partial look into pathing
- July 19th, 2016: For today's #haskell exercise we count crows. I mean triangles ... I mean (properly) trigons
- July 15th, 2016: I posted this problem on github this morning but did not announce: #Haskell exercise: extract date from twitter JSON So, BANG! right on the heels of the exercise announcement: Data.Aeson and a little Day-parsing for the solution.
- July 14th, 2016: Today's #haskell exercise ... get this! ... helps you find Haskell exercises, both problems and solutions! #graph For today's #haskell solution I went the graph DaaS-route to extract @1HaskellADay problems and solutions
- July 12th, 2016: Today's #haskell excercise compiles the RID into a Haskell module and analyzes Pride and Prejudice
- July 11th, 2016: Today's #haskell exercise decodes the RID/Regressive Imagery Dictionary from JSON
- July 8th, 2016: Today's #haskell exercise brings together replacing one set of symbols with another and qualified names in XML The #haskell solution today WEARYs me, but it, surprisingly, has COFFEE, so I'm good! Encoding strings-as-symbols.
- July 7th, 2016: Today's #Haskell problem is to write Bram Stoker's Dracula as Jane Austen would have ... erhm, sort of. Not literature: a rehash of Bram Stoker's Dracula using Jane Austen's words .. but then: have you read the original?
- July 6th, 2016: So, loading up an encoding table is on the plate for today's #haskell exercise. We encode Pride and Prejudice as symbols then save it as a #haskell module
- July 5th, 2016: We look at encoding names and qualified names for today's #haskell exercise. For today's #haskell solution we encoded (qualified) names as symbols using SymbolTable
- July 4th, 2016: (summary) Report generation is the name of the game for today's #haskell exercise. And so in today's #haskell solution we generate a report! BOOP!
- July 1st, 2016: *WHEW* It took two days to marshall the data set for today's #haskell exercise: convert junit test result-XML to CSV And the #haskell solution involves TagSoup parsing at applicative functors

## Thursday, July 14, 2016

### 1HaskellADay 1Liners June 2016

- June 13th, 2016:

You want this list:`[1, -1, 1, -1, ...]`

How would you produce this value in #Haskell ?- Wai Lee Chin Feman @wchinfeman

https://gist.github.com/skatenerd/08d70c45499e1610206a

(set plop to be identity, and set transformstate to be (*) -1) - Philipp Maier @AkiiZedd `
`iterate negate 1`

’ - Patrick Mylund @pmylund
`concat $ repeat [1, (-1)]`

- Gary Fixler @gfixler No need for the parens in a list.

- Jeff Foster @fffej and Kevin Meredith @Gentmen
`iterate (* (- 1)) 1`

- Spencer Janssen @spencerjanssen and Андреев Кирилл @nonaem00
`cycle [1, -1]`

- Philipp Maier @AkiiZedd:

I’m curious: Since concat is O(n) wouldn’t it take more and more time depending on how many items you take? - Patrick Mylund @pmylund Looks like they compile to the same thing https://gist.github.com/patrickmn/9a92ab2a088018b2c0631f3bcfd60ebe
- Philipp Maier @AkiiZedd I’m actually surprised the compiler can optimise this away :o Thanks for showing me
`ddump-simpl`

! - Eyal Lotem @EyalL
`concat`

is`foldr (++)`

, not`foldl`

. O(1) work is done to produce the next item.`[1,-1]++([1,-1]++(...`

- Philipp Maier @AkiiZedd:

- Wai Lee Chin Feman @wchinfeman
- David Turner @DaveCTurner I'd actually write '
`cycle [1,-1]`

' but I like the elegant, alliterative obscurity of '`iterate negate 1`

' - Fatih Karakurt @karakfa
`alt=1:[-x|x<-alt]`

Subscribe to:
Posts (Atom)