# Snap! 4.0

Version of implementation Snap! of programming language ScratchA version of Snap! programming language.

## Examples:

### Hello, World! - Scratch (498):

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!

### Factorial - Scratch (499):

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!

### Factorial - Scratch (500):

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!

### Fibonacci numbers - Scratch (501):

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!

### Quadratic equation - Scratch (502):

In Snap! block `join`

conveniently allows to concatenate arbitrary number of arguments.

Quadratic equation in Snap!

### CamelCase - Scratch (503):

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 `isLetter`

, `toLower`

and `toUpper`

, equivalent to functions of the same name in other languages.

CamelCase in Snap!

## Comments

]]>blog comments powered by Disqus

]]>