Skip to content

Instantly share code, notes, and snippets.

View jbunke's full-sized avatar
😵
ständig am ackern

Jordan Bunke jbunke

😵
ständig am ackern
View GitHub Profile
@jbunke
jbunke / prime.js
Last active September 7, 2024 12:48
Simple prime number checker script in DeltaScript that showcases new language features: `when` statement and lambda expressions
// 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).