code golf

2008-12-17 Thread rzeze...@gmail.com
Neat challenge on stackoverflow: http://stackoverflow.com/questions/372668/code-golf-how-do-i-write-the-shortest-character-mapping-program I added an implementation in Clojure. One that I'm sure could be greatly improved on. I don't really care for the extremely obfuscated examp

Re: code golf

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 6:15 PM, rzeze...@gmail.com wrote: > > Neat challenge on stackoverflow: > http://stackoverflow.com/questions/372668/code-golf-how-do-i-write-the-shortest-character-mapping-program > > I added an implementation in Clojure. One that I'm sure could be &

Re: code golf

2008-12-17 Thread Stephen C. Gilardi
On Dec 17, 2008, at 8:09 PM, Chouser wrote: But I can't deny that golfing is fun! Yes it is! (defn enc[s e](apply str(map(into{}(for[[o _ n](partition 3 4 e)][o n]))s))) Nice job as usual, Chouser! Here's my stroke--now shown to have landed well into the rough: (defn enc[p t](let[a app

Re: code golf

2008-12-17 Thread rzeze...@gmail.com
On Dec 17, 8:09 pm, Chouser wrote: > > I don't think I agree with the premise of the question, that golf > answers help anyone learn about other languages. > > But I can't deny that golfing is fun! > > (defn enc[s e](apply str(map(into{}(for[[o _ n](partition 3 4 e)][o n]))s))) > > I can't figu

Re: code golf

2008-12-17 Thread Mark Engelberg
This shaves 14 characters off of Chouser's solution: (defn enc[s e](apply str(map(apply hash-map(take-nth 2 e))s))) rzezeski: The problem statement is somewhat ambiguous about what to do if the character is missing from the mapping. It says you can just "skip it", and this short solution does

Re: code golf

2008-12-17 Thread rzeze...@gmail.com
On Dec 17, 9:53 pm, "Mark Engelberg" wrote: > This shaves 14 characters off of Chouser's solution: > (defn enc[s e](apply str(map(apply hash-map(take-nth 2 e))s))) > > rzezeski:  The problem statement  is somewhat ambiguous about what to > do if the character is missing from the mapping.  It sa

Re: code golf

2008-12-17 Thread Mark Engelberg
78? I count 72 after you take out all the superfluous spaces. But I agree that it says nothing significant about the language. It's a fun optimization puzzle, though, and can help understand whether the built-in library of functions is fairly rich. --~--~-~--~~~---~-

Re: code golf

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 9:53 PM, Mark Engelberg wrote: > > This shaves 14 characters off of Chouser's solution: > (defn enc[s e](apply str(map(apply hash-map(take-nth 2 e))s))) Very nice! --Chouser --~--~-~--~~~---~--~~ You received this message because you are

Re: code golf

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 9:53 PM, Mark Engelberg wrote: > > This shaves 14 characters off of Chouser's solution: > (defn enc[s e](apply str(map(apply hash-map(take-nth 2 e))s))) Which leads me to this, though it fails for reasons that escape me: (defn enc[s e](apply str(map`{~@(take-nth 2 e)}s))

Re: code golf

2008-12-17 Thread Timothy Pratley
>>`{0~@(cons 0 (take-nth 2 %2))} o_O I tried the `...@v} splice in but never imagined doing that! nice :) On the subject of splice in, am I alone in thinking (str ~...@v) is more readable than (apply str v)? Of course the former doesn't work as there is no preceding syntax- quote, but bea

Re: code golf

2008-12-18 Thread lpetit
Hello, On Dec 18, 5:49 am, Chouser wrote: > Which leads me to this, though it fails for reasons that escape me: > (defn enc[s e](apply str(map`{~@(take-nth 2 e)}s))) This one maybe fails because ~@ is a reader form that needs to expand at compile time. So if at compile time, e is not known (e.g