Compare commits

..

No commits in common. "4da3c5ac06ba30e6f18c174a99275790cf5f75df" and "5994a2d8f4723ec07d1ca6a61be07d4121697b24" have entirely different histories.

3 changed files with 3 additions and 24 deletions

View File

@ -1,18 +0,0 @@
#!/usr/bin/env shrimp
# usage: dice <sides>
import math only=random
import list only=first
import str only=[replace starts-with?]
sides = $.args | first
sides ??= 20
if sides | starts-with? d:
sides = replace sides //\D// ''
end
sides = number sides
echo 'Rolling d$sides...'
random 1 sides | echo

View File

@ -141,7 +141,7 @@ export class Tree {
// TODO: TEMPORARY SHIM // TODO: TEMPORARY SHIM
class SyntaxNodeType { class SyntaxNodeType {
constructor(public nodeType: NodeType, public isError: boolean) { } constructor(public nodeType: NodeType) { }
is(other: string) { is(other: string) {
return this.nodeType === other return this.nodeType === other
@ -333,7 +333,7 @@ export class SyntaxNode {
} }
get type(): SyntaxNodeType { get type(): SyntaxNodeType {
return new SyntaxNodeType(this.#type, this.#isError) return new SyntaxNodeType(this.#type)
} }
set type(name: NodeType) { set type(name: NodeType) {

View File

@ -16,10 +16,7 @@ export const math = {
if (n < 0) throw new Error(`sqrt: cannot take square root of negative number ${n}`) if (n < 0) throw new Error(`sqrt: cannot take square root of negative number ${n}`)
return Math.sqrt(n) return Math.sqrt(n)
}, },
random: (min = 0, max = 1) => { random: () => Math.random(),
if (min === 0 && max === 1) return Math.random()
return Math.floor(Math.random() * (max - min + 1)) + min
},
clamp: (n: number, min: number, max: number) => { clamp: (n: number, min: number, max: number) => {
if (min > max) throw new Error(`clamp: min (${min}) must be less than or equal to max (${max})`) if (min > max) throw new Error(`clamp: min (${min}) must be less than or equal to max (${max})`)
return Math.min(Math.max(n, min), max) return Math.min(Math.max(n, min), max)