Skip to content

Instantly share code, notes, and snippets.

@benqus
Last active August 29, 2015 14:05
Show Gist options
  • Save benqus/cc245b5eb199c9899691 to your computer and use it in GitHub Desktop.
Save benqus/cc245b5eb199c9899691 to your computer and use it in GitHub Desktop.
fjs - idea
http://pastebin.com/zKpJY9ck - copy from there
# single line comment
##
multi line comment
##
# variable assignment
a = 7.
# ######### #
# functions #
# ######### #
# anonymous function declaration
# - inside the function an line is terminated by a comma (,)
# - a function's end is determined by a full-stop (.)
# - a function's return value is the return value of the last line's expression/value
# - argument can have a default value if it isn't specified by the caller (d = 4)
# - splat argument (rest...) is an
# synthax
( [function head] )>
,
.
# Example:
(c, d = 4, rest...) >
a = rest[0],
b = [a].
# named function declaration
f ( ... ) > .
# function expression
f = () > .
# named function expression
f = _f () >
_f().
# self-invoking function
# - end in an exclamation mark
() >
,
!
f () >
!
# value of "f" will be the return value of the self invoking anonymous function declaration, NOT the function
f = () >
,
!
# ######### #
# condition #
# ######### #
# - equal sing (=) means triple equal (===)
# - inside the condition a line is terminated by a comma (,)
# - a condition's end is determined by a full-stop (.)
# - AND is represented by a comma (,) - only inside the condition's core
# - OR is represented by a semi-colon (;) - only inside the condition's core
# - grouping is allowed - wrapping multiple expressions in parentheses
# synthax
?( [condition head] ,;)>
,
.
# Example 1:
? ( a < 6, b = 10; c = 3, f() ) >
x = 5,
y = 6.
# Example 2:
? (
a < 6 and b = 10 or
c = 3 and f()
) >
x = 5,
y = 6.
# ###### #
# switch #
# ###### #
# - BREAK is the full-stop (.)
# synthax
@( [switch head] ):,. .
# Example:
a = 3.
@ (a)
# equal to ? (a = 1) >
1 : firstMethod().
2 :
3 : secondMethod(),
thirdMethod(). # multi-cases
4 :
fourthMethod(),
fifthMethod().
: sixthMethod(). # default case
. # end of switch
# ##### ###### #
# smart switch #
# ##### ###### #
# - translates to if ... else conditions
# synthax
@@( [smart switch head] ) : [short expression],. .
# Example:
a = 5.
@@ (a)
< 4 : doSomething() .
= 4;
= 5 : ... .
> 6 :
: ... . # default case
.
# ##### #
# loops #
# ##### #
{ i [index], v [value] : c [collection] } >
a = c[i],
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment