Download or view formatterTest.frink in plain text format
form=input["Enter formatter", "Input"]
// The noEval or $$ is necessary to prevent the internal string interpolations
// from happening.
// Think about how to prevent this more generally, like a non-interpolating
// string.
a = parseToExpression["""
if x < y ? true : false
{
c = 1000
println["This is a thing."]
} else
c = 100
if x < y
c = 1000
else
{
println["This is a thing."]
c = 100
}
if x
{
if y
c = 9
} else
c = 4
if x
{
if y
{
c = 11
println["second"]
}
} else
c = 7
i = 0
DOLOOP2:
do
{
i = i + 1
println["hi"]
if 2 > 3
break DOLOOP2
if 1 conforms 2
break;
} while i<c
DOLOOP1:
do
i = i + 1
while i<c
THING2:
while (i<=c)
{
i = i + 1
print["$$i "]
if [a,b] = "These are\\ntests." =~ %r/([\n\u0065])/g
println[a]
"these are tests." =~ %s/\x65/X/g
}
THING1:
while (i<=c)
i = i + 1
"""]
println[format[a, form]]
forloop = parseToExpression["""
d1 = new dict
d2 = new dict[[[1, "one"], [2, "two"]]]
OUTERFOR:
for b = 1 to 2
{
monkey = 1000
println["Thanks"]
for d = 1 to 3
{
c = c + 1
println[" monkey"]
if 1 > 3
next OUTERFOR
}
for e = 1 to 2
println["Done. "]
}
MULTI1:
multifor [a,b] = [new range[1,2], new range[3,4]]
{
println["$$a $$b"]
if a > b
next MULTI1 0
}
try
a = b
finally
{
println[" in finally"]
println[" wooo!"]
}
sqr = {|var x=10| x^2}
double = {|x is isInteger = 10, dummy1=3|
println[x]
return 2x
}
e = getFunction["exp", 1]
var f is [isPrime, isInteger] = 3
var o = new OrderedList[]
o.insertAll[[5,2,1]]
"""]
println[format[forloop,form]]
Download or view formatterTest.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20217 days, 23 hours, 34 minutes ago.