Snap! 4.0Version of implementation Snap! of programming language Scratch
A version of Snap! programming language.
Unlike Scratch, in Snap! each script must start with a “hat” block defining the condition upon which the script runs. “When green flag clicked” hat runs the script upon presentation start.
Hello, World! in Snap!
This example shows iterative calculation of factorial. To output results in required multiline format a global list variable is used.
Factorial (iterative) example in Snap!
This example uses recursive method of factorial calculation. Snap! allows to create user-defined blocks, in this case
factorial block of type reporter (a block that returns a value, i.e. a function block). The newly defined block appears in the blocks palette immediately, and can be used when editing its own definition, thus allowing recursive calls.
Factorial (recursive) in Snap!
This example uses recursive calculation of Fibonacci numbers. To speed up calculations, newly found numbers are written to “cache” which is simply a global list.
Fibonacci numbers (recursive) in Snap!
In Snap! block
join conveniently allows to concatenate arbitrary number of arguments.
Quadratic equation in Snap!
Snap! has a slightly larger list of built-in blocks than Scratch; for example, blocks
unicode of _ and
unicode _ as letter are built-in. In this example these blocks are used to define blocks
toUpper, equivalent to functions of the same name in other languages.
CamelCase in Snap!