-
-
Save rightfold/f44a8c7f783b63cd5d30 to your computer and use it in GitHub Desktop.
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
PreconditionViolation <- subclass Error { | |
constructor { |this.| | |
this.name := "PreconditionViolation" | |
this.message := "precondition violation" | |
stackFrames <- (new Error).stack.split "\n" | |
stackFrames.splice 1 3 | |
this.stack := stackFrames.join "\n" | |
} | |
} | |
require <- { |condition| | |
if (! condition) { throw: new PreconditionViolation } | |
} | |
fib <- { |n| | |
require: >= n 0 | |
if (< n 2) {1} { + (fib: - n 1) (fib: - n 2) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment