Keith Devens .com |
Wednesday, July 9, 2008 | ![]() |
| REMEMBERS- HEEL BARES DURID! BARE DURIDS IS STORNG FREND! – Alamo | ||
|
| ← Uncrittable druid w/o pvp gear | The FAIL Blog → |

Revence (http://freeshells.ch/~revence) wrote:
Keith (http://keithdevens.com/) wrote:
Yeah I didn't actually execute that Ruby code. I assumed you could take a reference to the method like that, but of course you can't since Ruby lets you call methods without parens. Anyway, the example doesn't change much. Thanks for the correction.
I mean, if you can't get type-inference (the ML-family way), you are better off without static types.
Totally. Like I tried using Array.ConvertAll without the <string, string> on the end, and I got a compiler error saying it couldn't figure out what it was supposed to map to, even though AllKeys returns a string[], the delegate takes a string as a parameter, and the delegate returns a string.
Revence (http://freeshells.ch/~revence) wrote:
And I swear I would love to use the .NET delegates. A lot. But the syntax is hideous in C#, it was, for long, scarier than C's function pointers. I'm resigned to doing F# if I have to do .NET programming. It's not that often, but still. I'm scarred from having looked C# in the face after a long, long time in the Python/Ruby/Haskell world. 
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):
Generated in about 0.216s.
(Used 8 db queries)

I think your Ruby code is lacking a .call on the use of the e variable. Maybe you meant:
e = URI.method :escape
qs.collect {|k, v| e.call(k) + '=' + e.call(v)}.join('&')
For one, I don't know how anybody stands using these Java-esque languages. I mean, if you can't get type-inference (the ML-family way), you are better off without static types. Yet even Ruby feels a tad unwieldy (and unsafe) when juxtaposed with a more-functional alternative like SML, OCaml, or (my fave) Haskell.
e = (flip Network.URI.escapeString) reserved
concat $ intersperse "&" [k ++ "=" ++ v | (k, v) <- Data.Map.toList qs]
That is the equivalent in Haskell. I assumed that qs would be a map (corresponds to a pure hashtable). It's pretty.