[Haskell-cafe] List all multiply/add combinations

Rune Harder Bak rune at bak.dk
Sun Nov 18 20:31:23 CET 2012

On Sun, Nov 18, 2012 at 2:04 PM, Stefan Klinger
<all-lista at stefan-klinger.de> wrote:
> Sounds like you would want to enumerate all possible *abstract* syntax
> trees, these implicitly have exactly the necessary parentheses.  I'd do
> this recursively, splitting the sequence of numbers in two at all
> possible places, and then combine the corresponding results with all
> possible operators.

That was my second idea, but just doing it naively resulted in many
equivalent calculations,
so I thought there might be a better way to view the problem.
But as Artyom showed

On Sat, Nov 17, 2012 at 11:37 PM, Artyom Kazak <artyom.kazak at gmail.com> wrote:
> Indentation messed up… I have pasted the code here: http://hpaste.org/77864

enumerating the abstract syntax tree is actually (or at least could
be) the way to go!
Thanks a lot! What I need is a little bit different, but now I feel
I'm on the right track!

This is my first question to the café and it makes me a lot more
certain using Haskell for production,
when you can get this kind of quick and thorough help when in doubt.

Great community!


More information about the Haskell-Cafe mailing list