The Editor is a software program we use to write Code. Our Editor allows us to experiment with Code on the right-hand side, in the Interactions Area. For Code that we want to keep, we can put it on the left-hand side in the Definitions Area. Clicking the "Run" button causes the computer to re-read everything in the Definitions Area and erase anything that was typed into the Interactions Area.

Data Types

Programming languages involve different data types, such as Numbers, Strings, Booleans, and even Images.

  • Numbers are values like 1, 0.4, 1/3, and -8261.003.

    • Numbers are usually used for quantitative data and other values are usually used as categorical data.

  • Strings are values like "Emma", "Rosanna", "Jen and Ed", or even "08/28/1980".

    • All strings must be surrounded in quotation marks.

  • Booleans are either true or false.

All values evaluate to themselves. The program 42 will evaluate to 42, the String "Hello" will evaluate to "Hello", and the Boolean false will evaluate to false.

Operators

Operators (like +, -, *, <, etc.) are treated the same way as functions: after all, they have inputs and outputs and obey the same rules!

Applying Functions

Applying functions (and operators!) works much the way it does in math. Every function has a name, takes some inputs, and produces some output. The function name is written first, followed by a list of arguments .

  • In math this could look like f5 or g(10, 4).

  • In WeScheme, these examples would be written as (f 5) and (g 10 4).

  • Appling the operator to the inputs 1 and 2 would look like ( 1 2).

  • Applying a function to make images would look like (star 50 "solid" "red").

  • There are many other functions, for example num-sqr, num-sqrt, triangle, square, string-repeat, etc.

Functions have contracts, which help explain how a function should be used. Every contract has three parts:

  • The Name of the function - literally, what it’s called.

  • The Domain of the function - what types of values the function consumes, and in what order.

  • The Range of the function - what type of value the function produces.

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.