The Challenge
Create a function to parse to parse the signatures into an array of types. There are two types one is simple like Apple, t...
For further actions, you may consider blocking this person and/or reporting abuse
I have no idea of the purpose of this, but I never refuse a fun challenge :D
I use the proximity of your syntaxe with JSON to parse more easily.
runkit.com/gmartigny/5bdc0d1932ccd...
Works with inconsistent white-space but not with deeper nested complex types.
I hate regex. It's so easy to write and so hard to read. I tried to not use regex in my solution, but it was just easier.
Great solution, I believe yours is even easier to read than mine!
I love them for the exact same reasons =D
I am half-tempted to peak into the F# compiler source code, since it uses these exact type signatures and the Hindley-Milner type system. But it generates a syntax tree as the result. So the inner
(Banana -> Grape)
would become another expression tree.Ya I'm sure they make an AST. That would have been too complex for this challenge. You are more than welcome to show is how it's done though! ;)
Oh, not me. :o) I guess just pointing out another practical application. And the F# compiler is bootstrapped (written in F#).
I always love when a compiler is written with that language. Eat your own dog food!
What is the output supposed to be? This doesn't look like valid javascript.
I may have been typing directly into dev.to. lemme fix :D
It makes much more sense now :)
Thanks for catching that. Sometimes I gets the dumbs. :D
Better here than in production systems :P
That gives me a great idea. CI/CD system for blog posts! Haha
My solution using recursion:
note: this solution doesn't account for inconsistent whitespace.
This one takes white space into consideration:
It is highly ironic that the real world use case is somewhere in Fantasy Land.
lol. Trying not to laugh out loud in meeting. Thanks for that one!
I can definitely see the power in it!
I have not dug into Elixir at all. This block of code makes me curious. I like how you defined each parse step is.
Gonna have to add it to my list of languages to learn.
Thanks for sharing.