free software resistance
the cost of computing freedom is eternal vigilance
### p02
*original date:* jun 2015
*originally posted:* sep 2024
early fig tutorial:
```
arrays... arrays are like a row of variables with the same name. so if `ed` is our variable, an array would be like ed and his clones:
* ed1
* ed2
* ed3
* edcetera (...sorry.)
only those are all valid variable names. what we need to do is put ed in a cloning vat. we do that with the `arr` command:
`ed arr`
before, `ed`was a single variable. now he is a single array with the same name. in python, ed looked like this before:
`ed = 0`
but now, ed would look like this in python:
`ed = [0]`
the brackets (which you dont use in fig) distinguish a single variable from an array. `0` is just the number zero, but `[0]` is an array containing a zero.
just to prove it, try this:
ed 0 print
ed 0 arr print
that will print `0`, then `[0]`.
here is what each command line does:
first:
* create ed
* set ed to 0 (ed was set to 0 anyway, this is more explicit.)
* print ed
next command line:
* zero ed (yes its redundant)
* set ed to 0 (incredibly redundant now)
* *convert ed to an array* containing *what ed contained before the conversion*
* print ed (which is now an array)
**fun fig fact: ** when you start a line with a variable, such as `ed 0 print`, ed gets set to 0. **however, arrays are immune** to this. so if you want to zero out an array, be explicit:
ed 5 arr
ed print
ed 0
here is what that does:
* set `ed` to `5`, then convert to `[5]`
* start line with `ed`, and `print` (right: print ed: `[5]`)
* set `ed` to `0` explicitly, since arrays are not implicitly set to 0 when they start a line.
in the previous lesson, we covered the `plus` and `times` commands. they will add "floating" (or "decimal") numbers, and/or integer ("whole") numbers. they will also add strings:
`ed "hello" plus " there" print`
and they can add arrays:
ed arr plus 5
ed plus 7
the first line creates `ed`, which is 0, then creates an array, which is `[0]`, then adds `5`, so now you have an array containing both:
`[0, 5]`
then on the next line, we take `ed` and `plus 7`:
`[0, 5, 7]`
so 0 `plus 5 plus 7` is 12. but if `ed` is `[0]`:
`ed plus 5 plus 7` is `[0, 5, 7]`
thats arrays. you can do great things with arrays, like load a whole text file into one:
`ed arropen "file.txt"`
that opens a file called `"file.txt"` and makes `ed` hole each line of that file in an array.
it would be nice to start installing python. if youre using a mac(book) or gnu/linux, just open the terminal and type **python** to start python.
among other things, you will get this prompt:
`>>>`
type `quit()` (dont forget to hit "enter" or "return") to leave python. it will probably still say what version of python you have.
if you have a mac or gnu/linux, hopefully running **python** gives you 2.7.something. if not, try **python2** as a command instead. `quit()` (enter) to quit that one.
if you dont have python2 installed, you will need it to run fig. i do not know how to install python2 on a mac (it used to/still comes preinstalled on a mac.)
on gnu/linux, python3 is not the default yet (debian, ubuntu), so python2 should be installed already.
if you are using windows, just install the 32bit version of python 2 from here:
double u double u double u dot python dot org: /ftp/python/2.7.10/python-2.7.10.msi
install that, hold down your super key (it has a windows logo) on your keyboard, and hit "r" (window-r.) this brings up a run window. type **cmd** (enter) and type **python** in the black command window.
**if** this doesnt work, find where the python program is installed. you will need python (2) installed before anything else, if you wish to use fig.
if you prefer not to install python and fig, that is alright. the lesson can continue without having it installed, although there is never a substitute for actual use.
you dont learn a language without using it; but, you can evaluate a class-- somewhat-- regardless. at least on clarity.
cheers... questions encouraged as usual.
```
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