Created
August 12, 2012 15:55
-
-
Save cowboy/3332446 to your computer and use it in GitHub Desktop.
LiveScript: language design?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Re. the LiveScript <-! operator (et al) | |
// http://gkz.github.com/LiveScript/ | |
function getLiveScriptOperator() { | |
var op = ''; | |
for (var i = 0; i < 3; i++) { | |
op += String.fromCharCode(33 + Math.floor(15 * Math.random())); | |
} | |
return op; | |
} |
@michaelficarra (do)
works too, plus you can change your <|
with a ,
here.
My version also is shorter: '-!+'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @qfox, yes it is a joke. It is an exercise in code golf to see what is the shortest definition.
An explanation of:
First,
is a list comprehension. It is an expression which evaluate to a list. It is equivalent to:
As the
from
parameter is omitted in the for loop, it is assumed to be0
.to
means to and including that number, usetil
to mean up until (but not including) that number.simply means