This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ignore .js file extension - only used so GitHub's JavaScript linter provides decent code highlighting | |
/* | |
This script accepts an integer `to_check` and returns true if and only if it is a prime number. | |
Note the use of a when statement, DeltaScript's answer to switch statements. | |
Cases in when statements take three forms: | |
1. `is` cases compare the control expression against an expression and execute their body if the values are equal | |
2. `passes` cases provide a predicate that the control expression is tested against. | |
For a control variable of type T, predicates are functions of type (T -> bool). |