free software resistance
the cost of computing freedom is eternal vigilance
### comp.txt
*original date:* feb 2015
*orginally posted:* sep 2024
early file comparing fig, basic and python:
```
fig basic python
, optional separator x, 5, print x = 5 : print x x = 5 ; print x
don't change var:
print x 5 print x = 5 : print x x = 5 ; print x
prints x prints print x; x = 5 ; import sys
sys.stdout.write(x)
(x is a variant) (in some dialects) (x is a variant)
system x system system quit()
end x end end quit()
sleep __ x sleep 5 sleep 5 import time;time.sleep(5)
colortext __ x colortext 5 color 5 color(5, None)
highlight __ x highlight 5 color ,5 color(None, 5)
return __ x 5 return x x = 5:funcname=x x = 5 ; return x
swap __ __ z swap x y swap x, y x, y = y, x
locate __ __ z locate r c locate r, c locate(r, c)
pset __ __ __ pset x y c screen 12:pset(x,y),c # use gasp or pygame
do this to main var:
-12345.67890 x -3.2 int abs x = abs(int(-3.2)) x = abs(int(-3.2))
12345.67890 x 3.2 int abs x = abs(int(3.2)) x = abs(int(3.2))
str x 50 str x$ = str$(50) x = str(50)
chr x 100 chr x$ = chr$(100) x = chr(100)
hex x 16 hex x$ = hex$(16) x = hex(16)
oct x 0 oct x$ = oct$(0) x = oct(0)
val x "5" val x = val("5") def figval(n):
n = float(n)
if float(int(n)) == \n
float(n):
n = int(n)
return n
x = val("5")
cos x 5 cos x = cos(5) import math;x=math.cos(5)
sin x 5 sin x = sin(5) import math;x=math.sin(5)
sqr x 5 sqr x = sqr(5) import math;x=math.sqrt(5)
timer x timer x = timer # see how fig does it
time x time x$ = time$ # see how fig does it
tan x 5 tan x = tan(5) import math;x=math.tan(5)
rtrim x "hi! " rtrim x$=rtrim$("hi !") x = "hi !".rstrip()
lcase x "hi" lcase x$=lcase$("hi") x = "hi".lower()
ucase x "hi" ucase x$=ucase$("hi") x = "hi".upper()
int x 5.5 int x = int(5.5) x = int(5.5)
in fig: x "hello" time timer sqr str lcase
in basic: x$ = "hello" : x$ = time$ : x$ = lcase$(str$(timer))
in python: x = "hello" ; x = time() ; x = str(timer()).lower() # plus time(), timer()
get __ function hi p function hi(p) def hi(p):
x get p x = p x = p
left __ x "hi" left 1 x$ = left$("hi",1) def left(p,s):return p[:s]
x = left("hi", 1)
right __ x "hi" right 1 x$ = right$("hi",1) def right(p,s):return p[-s:]
x = right("hi", 1)
note: basic and python use order-of-operations ;
fig does math like you're punching it into a pocket calculator
plus __ x 5 plus 2 times 7 x = (5 + 2) * 7 x = (5 + 2) * 7
times __ x 5 times 2 plus 7 x = 5 * 2 + 7 x = 5 * 2 + 7
divby __ x 5 divby 2 x = 5 / 2 x = float(5) / 2
minus __ x minus 5 x = 0 : x = x - 5 x = 0 ; x = x - 5
mod __ x 7 mod 2 x = 7 mod 2 x = 7 % 2
topwr __ x 2 topwr 20 x = 2 ^ 20 x = 2 ** 20
string __ __ x string "h" 5 x$=string$("h",5) x = "h" * 5
string __ __ x string 104 5 x$=string$(104,5) x = chr(104) * 5
mid __ __ x "hello" mid 4 2 x$=mid$("hello",4,2) def mid(p, s, x):
return p[s-1:x+s-1]
randint __ __ x randint 8 9 randomize timer import random
x = int(rnd*2 + 8) random.randint(8, 9)
this must begin a line:
function ?__ ?__ ?__... function p x y z function p(x, y, z) def p(x, y, z):
n get x return n n = x : p = n n = x
fig end function return n
for __ __ __ __ for z x y 1 for z = x to y step 1
next p z print p = z : print p for z in range(x,y+1,1):
fig next p = z : print p
while while while while 1:
wend break exit while break
fig wend
iftrue __ iftrue 1 if 1 then if 1:
p "y" print print "y" print "y"
fig end i
pass pass 'do nothing pass
break break exit while/do/for... break
try try on error goto 10 try:
x divby x x = 0 ; x = x / x x = 0 ; x = x / x
except except except:
print "you can't" print "you can't"
resume resume
python python shell "python -c " + # look, more python:
# inline python here # inline python
# more inline python # more
fig fig fig # um... fig
# either is fine
textmode textmode screen 0 pygame.quit()
graphics graphics screen n + 1 pygame.init() #+ more
notes:
(real) graphics init automatically when graphics statements are used...
"textmode" forces graphics mode off, graphics commands render in color text.
"graphics" returns to default mode ; turns real graphics on (or tries. needs pygame.)
"fig" is means "unindent." in python unindenting is like "end if", "next", "end function",
"wend"... etc.
aliases for "fig" include wend, next, resume. you can use "fig" for all of these.
fig exits inline python mode. "python" enters python mode, "fig" returns to fig mode.
```
license: 0-clause bsd
```
# 2015 mn
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
```
=> https://freesoftwareresistance.neocities.org