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

Dejan Panovski Outs linuxize.com as a Slopfarm, Another Site That Sold Out and Became LLM Garbage
From what we can gather, both images and text are slop
A Microsoft Lunduke OS (LCOS) is Not Even in Top 100 in DistroWatch, Microsoft Lunduke Just Games the Numbers Like Linspire Did (and Got 'Banned' for It)
Linspire used to send people to 'its' DistroWatch page to make the illusion of popularity
 
Gemini Links 27/09/2026: Writing Well, Productivity, and a Relaunch in Geminispace
Links for the day
Making This Site More Useful to More People
Search engines (as a concept) are under attack
Exposing Crimes of Americans (From the UK)
We must ensure UK prisons are never misused to punish/silence people who expose crimes in America
Spam and Chatbot Spam in Internet Relay Chat (IRC)
Maintaining one's own IRC network requires some housekeeping, but it's simpler than outsourcing to malicious companies
Search Engine of Techrights Improved for Better Signal-to-Noise Ratio
Our growing community needs more search facilities
Microsoft: We Love Layoffs, We Do Silent Layoffs, More Microsoft Projects/Teams/Studios Confirmed to be Shutting Down
XBox is dying. Piece by piece.
Brigading Against Women - Part VI - On Garrett and Lozza, Defamation, Attempts to Crack My Wife's Accounts, Social Engineering to Try to Take Sites Offline, Subscribing Us to Mountains of SPAM
tried swatting us
Links 27/09/2026: "Provost of Dartmouth Busted Using Hey Hi (AI) Slop for His Own Writing in Newspapers and Academic Journals" and "UK Government Enforcement Reform"
Links for the day
People and Sites Wish a Happy 43th Birthday to GNU (Today)
We've collected some examples
Links 27/09/2026: Microsoft Fired People a Day After Promotion, "Fragility of Online Journalism"
Links for the day
Brigading Against Women - Part V - SWATTING, Extortion Against Webhosts, and Lawfare Under Sworn Oath (Perjury Also)
Matthew Garrett has no qualm about still collaborating with Lozza
20 Years Later
There's a strong anti-democracy movement brewing in many places
Gemini Links 27/09/2026: Telescopes/Gskyer, Writing for Writing's Sake, and Writing Tools
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Saturday, September 26, 2026
IRC logs for Saturday, September 26, 2026
Gemini Links 26/09/2026: Computer Cases Dreary, Web Drowning in Botspam
Links for the day
Reform UK auditor: Electoral Commission accounts, Companies House accounts, a going concern or not?
Reprinted with permission from Daniel Pocock
European Patent Office (EPO) Series: Temporary Public Office or Permanent Personal Feather-Bed?
there are no visible signs that the Administrative Council has the slightest interest in contemplating a change in leadership at the EPO
Brigading Against Women - Part IV - Death Threats, Threats to Women, and Threats for Pointing Out, Correctly and Based on Hard Evidence, That Garrett and Lozza Talk to Each Other About Me Every Year (for 4 Years)
Brett Wilson LLP too is a toxic manosphere
More GAFAM Layoffs at Apple, Second Time in Weeks (Silent Layoffs Silently Target Older and "More Expensive" Staff)
How many layoffs happen at Apple silently and go unreported or very scarcely reported?
Gemini Links 26/09/2026: Rant About Slop Ruining Crafts (Drowning the Signal With Plagiarism) and "Going Mechanical"
Links for the day
Links 26/09/2026: Microsoft Says Notification Data Breach/Surveillance Hole There by Design, EU Rapidly Dumping Microsoft for Digital Sovereignty
Links for the day
The Former Linux News Site ostechnix.com is LLM Slop
Please do not link to sites that promote and/or spread slop
Links 26/09/2026: Volkswagen Recalling ~50,000 Cars, US Attacks Its Own Media
Links for the day
Making Oneself Obsolete With Slop
Dr. Lemire also puts on display a degree of hypocrisy
Brigading Against Women - Part III - Racism Looms Large, Not Just Sexism
threats from a racist
Microsoft CEO Calls Layoffs "Streamlining" and Says Microsoft Layoffs Are "Great to See"
The lack of honesty here is only to be expected from Microsoft
Media silence deafening as Reform UK on brink of administration
Reprinted with permission from Daniel Pocock
Gemini Links 26/09/2026: Travel, Group Insurance Death Spiral, Stargazing, and Lagrange Meets LLM Slop
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Friday, September 25, 2026
IRC logs for Friday, September 25, 2026
Longtime Symbol of Microsoft's XBox Franchise, Halo, Down to Barely 20 People
The purge is huge, far bigger than submissive media cares to point out
EPO Meeting Ran Out of Time to Discuss the Scabs ('Young Professionals')
EPO staff representatives in The Hague meet a member of the 'cocaine cabinet'
The Register MS Promotes Slop for Banned Companies That Put Chinese Back Doors in Things, "AI" Mentioned 37 Times in One Page!
taking money from the undemocratic state and its surveillance outfits
Microsoft Attacked European Courts and Jurists, Now Europe Dumps Microsoft
This is because GNU/Linux is technically better, but the political factors contribute to that as well
Julian Assange Ready to Talk More (After More Than a Decade of Arbitrary, Unjust Confinement)
Two years ago, upon his release, his wife said he'd need some time off before properly or fully returning to the public eye
IEEE Tribute to Richard Stallman, Michael Tiemann, Linus Torvalds, Larry Augustin, Eric S. Raymond, Bruce Perens, Frank Hecker and Brian Behlendorf (Revolution OS Showing)
Live shortly
Winding Up Racists
What happens next shall be interesting
Links 25/09/2026: Selling Rogue, Defective Bots as "Agents" Results in PR Fiasco and Breaches; Russian 'Hybrid Attack' and "How Russia Evades Sanctions"
Links for the day
Gemini Links 25/09/2026: Arvelie Calendar, 44net, Pebbles, and Building the Bagel Concert Finder
Links for the day
Large Wave of IBM PIPs, the RAs Wave Comes After 'Low-Hanging' Fruit (Families) Disposed of
PIPs are the new RAs
Links 25/09/2026: Carcinogen Atrazine Pollutes Americans' Bodies, "Donald the Deadbeat Does Diesel", and Anger Over Data Centres Grows
Links for the day
Theory That Microsoft Cheapens Its Workforce to Push Workers Out on Their Own (Theory Advanced by Insider)
people work longer hours for less, i.e. their hourly salary is decreasing
Daniel Pocock Makes It Into Mainstream Media Again (Going After Racists)
American bigots funding blatant and shameless racists here in the UK
Tackling Racism in the United Kingdom (Racism Funded by Americans) Using the Courts
We'll talk about racism my wife and I experienced in the events leading up to litigation
Another Woman (or Women) Has Just Run Away From Brett Wilson LLP (After Barely a Month!), the Hired Guns of Garrett and Graveley (Microsoft)
They call this phenomenon "death spiral"
SLAPP Censorship - Part 200 Out of 200: Will GNU Boot Undo the Technical Damage Caused by Microsoft and Garrett? (And Garrett's Litigation Allies From Microsoft)
Today we publish the final part of this series
US Government Sites Can Now Totally Ignore Mozilla Firefox Users or Users of Firefox Derivatives
Firefox, now at 1.1% in the US (based on American government sites), has sunken to the point of no return
Things Not to Measure in Quantity Alone
More patents do not beget greater innovation
Even Microsoft Boosters Start to Doubt XBox Will Exist (It's Being Phased Out, Just Not "Officially")
This is how to phase out a business unit without officially saying so (as it might alarm investors)
Omarchy is Built on the Idea That Slop is Desirable (It's Not)
They call bots and plagiarism "agents" and "training"
IBM is Shrinking Very Fast (Silent, Unannounced Layoffs)
IBM and Microsoft both avoid WARN notices by compelling staff to leave or silently removing them with some NDA
In Some Parts of Microsoft 50% of All Staff Subjected to Layoffs, Media Pretends Only 0.1% of Staff Are Removed
This really says a lot about the state of today's so-called 'media'
SLAPP Censorship - Part 199 Out of 200: An American Burden on the British Legal System
A year ago (October 2025) the head of media (Jointly in Charge of the Media and Communications List), the judge in the Garrett case, said that this case was a waste of the court's money
EPO Management Wants Everything to be Done in Microsoft Spyware
In reality, this management should be ousted for normalising cocaine at the Office
Criminalising Opposition to Fraud
slop causes social issues
The Register MS Does Not Properly Flag Its SPAM About Slop
Signs of desperation
Gemini Links 25/09/2026: Ljubljana, Tanana River, and Curse of Slack
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Thursday, September 24, 2026
IRC logs for Thursday, September 24, 2026
Supporters of winding-up process staking claims against Reform UK Party (CR-2026-007405)
Reprinted with permission from Daniel Pocock
Winding-up petition leaked before service on Reform UK Party Limited / Nigel Farage
Reprinted with permission from Daniel Pocock