Bonum Certa Men Certa

How To Write fig Programs

By figosdev

Young programmer



Summary: This is the second in a two-part series on fig

This is the second in a two-part series on fig, an educational language that I use for other practical purposes.



Because I designed fig for computerphobes, you may decide it has a few odd qualities. One example is that it uses a "plus" command instead of + and a "minus" command instead of -. It also has an inline Python feature, which can be used to import Python functions into fig programs, as well as allow more traditional expressions to be evaluated, if you prefer:

python
    import math
    evaluated = math.sqrt(p ** int(s / 2.5))
    fig


Fig has its own function definition command, which you can use to create functions with Python-like scope:

function greet whom
    now = "Hello, " plus whom ; print
    fig


Fig is the standard command that in Python would be unindenting, and it is named for "return to fig programming" after inline Python. In most instances, you can use "next" if you prefer:

function greet whom
    now = "Hello, " plus whom ; print
    next


You can use this as a wrapper around a python feature like this:

function pi
python
    from math import pi as ppi ; return ppi
    fig
    fig   



r = 50 circumference = pi times 2 times r ; print


In fig, the only mandatory punctuation in syntax is "quotes for strings" and # hashes for comments. Decimal points work the same way they do in Python.

These characters are optional, and for the most part can be freely used to help visually organise your code: = ( ) | ; : ,

The vertical bar can be used to introduce students to Bash. With the exception of a few commands that start on their own line -- such as for, next, forin, ifmore, ifless, iftrue, ifequal, else, break, while, wend -- nearly all fig commands share a line with a variable on the far left:

height = 60 ; plus 5 ; str ; len ; print


height is 60, it adds 5 to become 65, is converted to a string: "65" then the length is found, and 2 is printed to the screen.

As in Python, there are a few ways to create arrays:

titles = "" ; arr ; times 100


This will create an array of 100 string items. you can add items like this:

titles plus "A History of Red Hat: From Cottage Industry to Corporation"


Each time a variable is used on the left, it is set to 0-- arrays are the exception:

now 5 print # prints 5
now print # prints 0
now 5 arr 
now print # prints [5]


You can create an array using split:

ingredients = "milk eggs sugar flour water" ; split ingredients " "


Unlike Python, split and join both put the variable to split or join first -- then the thing to split or join it with:

ingredients = "milk eggs sugar flour water" ; split ingredients " "
ingredients = join ingredients " " ; print


Arrays are 1-based (apologies purists, it's an educational language) and for loops are started with count-variable, start-var, stop-var, step-var:

ingredients = "milk eggs sugar flour water" ; split ingredients " "
howmany = ingredients ; len
for each, 1, howmany, 1
    now = each ; print
    next


Forin loops are started with value-tracking-variable, array:

ingredients = "milk eggs sugar flour water" ; split ingredients " "
forin each, ingredients
    now = each ; print
    next


(nextin can be used instead of next)

Files can be opened with arropen, and webpages with arrcurl:

urls = arropen "urls.txt"
buffer = arr ; mid 1 0 # zero-length array
newline = 10 ; chr 



forin each urls iftrue each geteach arrcurl each ; join geteach newline buffer plus geteach fig nextin


Failed downloads create an error, so add error trapping (no, this is not how you should do this in python -- it is just a simple introduction to error trapping)

try
        geteach arrcurl each ; join geteach newline
        buffer plus geteach
except
        geteach ""
        resume


Finally, you can open geany using fig:

openleafpad = "leafpad &" shell


Or get the output of shell commands into an array:

textfiles = "ls *.txt" arrshell


To compile your fig program, give it a .fig extension and run it this way:

$ fig46.py program.fig



$ ./program.fig.py


To get help on a command, type part of it into the help feature:

$ fig46.py help
print


It will return all commands containing "print" in the name. hit enter instead to list all commands.

This will not work:

$ fig46.py help print


This will:

$ echo print | fig46.py help


All commands:

$ echo | fig46.py help


Fig is based on Python 2 -- as much as the Python Foundation is trying to kill Python 2, I think it is a much friendlier language than the latest Python.

PyPy is Python 2 compatible, and is the interpreter fig will most likely to be paired with in the future. There are two factors being waited on: PyPy is planning to support Pygame (an optional component for fig that lets it do real graphics) and Python 2 is still supported by many distros, not least of all Debian, Devuan and Refracta.

The Python Foundation will officially drop Python 2 on January 1. If you love it anyway, try PyPy.

To make fig use PyPy instead, change the two lines that contain the string "env python2" to "env pypy" and that should do it. You can download fig 4.6 here.

Happy Coding!

Licence: Creative Commons cc0 1.0 (public domain)

Recent Techrights' Posts

Linuxiac May Have Reverted Back to LLM Slop (Updated Same Day)
Is he back off the wagon?
Links 15/01/2026: Internet Blackouts, Jackboots Society in US
Links for the day
The Last 'Dilberts' or Some of the Last Salvaged (Comic Strips Which Disappeared Shortly After They Had Been Published)
Around the time the creator of Dilbert went silent he published some strips mocking TikTok and usage of it
GAFAM is a National and International Threat to Everybody
GAFAM is just a tentacle in service of imperialism
Don't Cry for Gaslighting Media in a Country Which Loathes the Press
my wife and I received threats for merely writing about Americans
 
Links 15/01/2026: Starlink Weaponised for Regime Change (by Man Who Boasted About Annexing South American Countries for Tesla's Mining), Corruption in Switzerland Uncovered by JuristGate
Links for the day
GAFAM and IBM Layoffs Outline
a lot of the layoffs happen in secrecy and involve convincing people to resign, retire, relocate etc.
Coming Soon: Impact With EPO Cocainegate
Will Campinos survive 2026?
The Creator of Git Probably Doesn't Know How to Install and Deploy Git
Nobody disputes this: Mr. Torvalds created Git
Slop is a Liability
Slopfarms too will become extinct because people aren't interested in them
EPO People Power - Part XXXVI - In Conclusion and Taking Things Up Another Notch
They often say that the law won't deter or stop criminals because it's hard to enforce laws against people who reject the law
Running Techrights is Fun, Rewarding, and Gratifying
In Geminispace we are already quite dominant
Red Hat is Connected to the Military, Its Chief Comes From Military Family (From Both Sides)
The founder of Red Hat's parent company literally saluted Hitler himself (yes, a Nazi salute)
Red Hat (IBM) is Driving Away Remaining Fedora Users
I've not used Fedora since Moonshine
Robert X. Cringely Has Already Explained IBM's Bullying Culture (Towards Its Own Staff)
IBM is a fairly nasty company
Proton Mail compromise, Hannah Natanson (Washington Post) police raid & Debian
Reprinted with permission from Daniel Pocock
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Wednesday, January 14, 2026
IRC logs for Wednesday, January 14, 2026
Gemini Links 15/01/2026: "Ode to elinks", envs.net Pubnix and Downtime at geminiprotocol.net
Links for the day
Still Condoning Child Labour and Exploiting Unpaid Children Developers as PR Props (to Raise Monopoly Money)
These people lack morals. So they project.
"Security, AI or Quantum" on "the IBM Titanic"
Who's RMS?
Hours Ago The Register MS Published Microsoft Windows SPAM "Sponsored by Intel." The Fake 'Article' Says "AI" 34 Times.
The Register MS isn't a serious online newspaper
EPO People Power - Part XXXV - Where Else Will Corruption and Substance Abuse be Tolerated?
We need to raise standards
Status and Capital
People who do a lot are too busy to boast about it and wear fancy garments
IBM Paying the Price for Treating Workers Badly and Discarding Real Talent (Because It's "Expensive")
IBM is dead man walking
Turbulence Ahead
I last rebooted my laptop in 2023
Google News Rewards Plagiarism With LLMs (About Linux, Too)
Google is in the slop business now
Links 14/01/2026: Failing Economy and Conquest Abroad as a Distraction From Domestic Woes
Links for the day
Gemini Links 14/01/2026: The Ephemerality of Our Digital Lives and "Summer of Upgrades"
Links for the day
Projection Tactics - Part III: Silencing Inconvenient Voices Online
If X gets banned in the UK, it'll be hard to see what the spouse says in public
Outsourcing on Microsoft's Agenda, Offshoring Also
"In some cases, India hiring is poised to replace certain roles previously based in the U.S."
Links 13/01/2026: 'Dilbert' creator Scott Adams Passes Away With Cancer, Ban on X/Twitter Considered for CSAM Profiteering
Links for the day
The Goal is Software Freedom for All
Anything to do with "Linux Foundation" is timewasting
Reminder That Red Hat Enterprise Linux (RHEL) Is Not Free, And It's Because of IBM
software freedom just 'gets in the way'
Under IBM, in Order to Game the Stock Market, Red Hat Resorted to Boosting the Biggest Ponzi Scheme in Human History
This is what IBM turned Red Hat into
Revision handed Microsoft the keys to the distortion of the past/history
This isn't the first time The Register MS rewrites computing history in Microsoft's favour, as we pointed out several times in past years
What Will Happen to GAFAM After the US Defaults Rather Than Bails Out the Market?
Or tries to topple every government that doesn't play by its rules?
EPO People Power - Part XXXIV - Bad Optics for the European Union (for Failing to Act and Tolerating Cocaine Use in Europe's Second-Largest Institution)
There are principles in laws which tie awareness with complicity
EPO's Central Staff Committee is Now Redacting (Self-Censoring) Due to Threats From the EPO "Mafia"
"On the agenda: salary adjustment procedure for 2025 (as of January 2026)"
"AI" (Slop) 'Demand' Isn't Growing, It's Fake, It's a Pyramid Scheme
They try to resort to 'creative' accounting (fraudulent schemes like circular financing)
Difficult Times at IBM and Microsoft Ahead of Mass Layoffs (Probably Before This Month's Results Unless Postponed to 'Prove' Rumours 'Wrong')
IBM and Microsoft used to be tech giants. Nowadays they mostly pretend by pumping up their stock and buying back their own shares.
Canonical: Make Ubuntu Bloated (Debian With Snaps), Then Sell the 'Debloated' Version for a Fee
If people want a light distro, then they ought not pay Canonical but instead choose a light (by design) GNU/Linux distro
People Don't Want "Just Enough", They'll Look for Quality
That's why slopfarms will go away or become inactive
Gemini Links 14/01/2026: 3D and Tiny Traffic Lights Pack
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Tuesday, January 13, 2026
IRC logs for Tuesday, January 13, 2026
Slop Waning Whilst Originals Perish
Slop is way past its "prime"
XBox's 'Major Nelson' Loses His Job Again, This Time in a Microsoft Mono Pusher
Microsoft hasn't much of a future in gaming. XBox's business is in rapid decline and people who push Mono to game developers are the same
Links 13/01/2026: Russia Weaponises Weather Against Civilians, Beijing-Controlled HK Attacks Legal Team of Besieged Critics
Links for the day
Gemini Links 13/01/2026: Loss of Desire to Produce, Individual Consumption
Links for the day
Shobhit Varshney From IBM Pushing Slop at Large Bank, Another McDonald's Waiting to Happen?
How long can they get away with phony narratives like "replaced by AI"?
Links 13/01/2026: Ubisoft Layoffs, "India IT In Shambles", and Microsoft Chatbot Killing People
Links for the day
IBM is Not a Leftist Company, the "I" Stands for Imperialism, and Poo Floats to the Top
Remember that AK is military from both sides of his family
Links 13/01/2026: More Mass Layoffs in GAFAM, Catching Up With Political News of Early January
Links for the day
Freedom of Speech in the UK (or Freedom of the Press/Expression) and Protection From Adversaries
undressing people without consent and in very bad taste is not "speech"
Ending the Status Quo at the European Patent Office (EPO) This Year
Things will continue to get worse as long as the "Digital Majority" stays silent and/or passive
Greenland Ought to Move to GNU/Linux, Not Apple
GNU/Linux at 4%
So When Will British Politicians, Police, Government Departments Quit Twitter (X.com)?
They sure bring constituents there (by being there)
If You Care About Freedom, Don't Follow IBM Red Hat (Like Microsoft Novell 20 Years Ago)
IBM Red Hat and Microsoft don't seem to compete
IBM Red Hat Does Not Compete With Microsoft, It's a Microsoft Reseller
even if employees of Red Hat dislike and distrust Microsoft
Red Hat Layoffs, Even of "AI" Staff in India
This is how companies die
LLM Slop Isn't Replacing Online News, It's Just a Pest That's Gradually Going Away as Money for Slop Runs Out
Slop likes to talk about itself (like some kind of 'web-cancer')
Not Journalism: Almost 80% of the 'Articles' We Saw About Torvalds and 'Vibe Coding' Are LLM Slop (Sometimes Slop Images)
The real issue is, Torvalds who created Git as a solution to proprietary prison is entertaining Microsoft's own proprietary prison
EPO People Power - Part XXXIII - Interest From Some European Media, For a Change
Without it, we'll become another Russian Federation
Just Another Reminder That Microsoft Didn't Deny Mass Layoffs
Remember that Microsoft never denied this
GNU/Linux Measured at 6% in Réunion This Year
Population sizes like a million people are nothing to sneeze at
Dr. Andy Farnell on Marketing Bad Things Like Slop Using FOMO (Fear of "Being Left Behind")
many of the same themes we often cover here
IBM Stock Compared to Bitcoin, Fake Articles About IBM Promote Myths About IBM
The stock moves based on false marketing
Bluewashing Continues, Red Hat Onboarding Interns in Low-Paid Regions
It's the end of the second Monday of 2026
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Monday, January 12, 2026
IRC logs for Monday, January 12, 2026
Gemini Links 13/01/2026: ScottoRang and Outage
Links for the day