|
|
On 05/09/2011 07:45 PM, Warp wrote:
> The lack of separators is also confusing to someone who is accustomed to
> programming languages that use separators.
Don't try Lisp. ;-) (Or Smalltalk. Or Tcl. Or...)
Anyway, just for giggles, I wanted to see if I could hack the language
hard enough to make it support separators. The answer is... yeah, kinda.
insert|< 5 # my_heap >|j
I can't get it to use a comma, colon, semicolon or any similarly
separator-like symbol, since these are all reserved symbols. The best I
could manage is #, @, $ or similar. (I did try more unusual Unicode
symbols, but that crashed the compiler - ridiculously enough...)
Obviously, the way I did this was to define some new operators. I could
have gone for
insert< 5 # my_heap >j
except that "<" and ">" are already in use. (You can reuse them... but
would you want to?)
You may also notice the stray "j" at the end. That's not a semicolon,
it's the letter J. Haskell doesn't support unary operators, only binary.
So the final >| must have two operands. It actually ignores the second one.
The code is quite simple:
f |< x = f x
f # x = f x
x >| y = x
j = undefined
That's literally it.
Post a reply to this message
|
|