Skip to content

Commit

Permalink
Implement int? (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbmivoice authored Oct 21, 2024
1 parent 155d17c commit dbf760d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ etc
(~ 10) → -11 ;Bitwise NOT
(div? 10 2) → true
(asin 1) (acos 1) (atan 1) (sinh 1) (cosh 1) (tanh 1)
(odd? 5) (even? 6) (pos? 5) (neg? -5) (zero? 0)
(odd? 5) (even? 6) (pos? 5) (neg? -5) (zero? 0) (int? 5)
(null? null) (num? 123) (bool? true) (str? "hi")
(dict? {}) (vec? []) (key? :abc) (func? +) (wild? _)

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "insitux",
"version": "23.12.5",
"version": "24.10.21",
"description": "Extensible scripting language written in portable TypeScript.",
"main": "dist/invoker.js",
"types": "dist/invoker.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const insituxVersion = 231205;
export const insituxVersion = 241021;
import { asBoo } from "./checks";
import { arityCheck, keyOpErr, numOpErr, typeCheck, typeErr } from "./checks";
import { isLetter, isDigit, isSpace, isPunc } from "./checks";
Expand Down Expand Up @@ -221,6 +221,8 @@ function exeOp(op: string, args: Val[], ctx: Ctx, errCtx: ErrCtx): Val {
}
case "div?":
return _boo(num(args[0]) % num(args[1]) === 0);
case "int?":
return _boo(Number.isInteger(num(args[0])));
case "average": {
const src = vec(args[0]);
let sum = 0;
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export const ops: {
"pos?": { exactArity: 1, numeric: "in only", returns: ["bool"] },
"neg?": { exactArity: 1, numeric: "in only", returns: ["bool"] },
"zero?": { exactArity: 1, numeric: "in only", returns: ["bool"] },
"int?": { exactArity: 1, numeric: "in only", returns: ["bool"] },
"null?": { exactArity: 1, returns: ["bool"] },
"num?": { exactArity: 1, returns: ["bool"] },
"bool?": { exactArity: 1, returns: ["bool"] },
Expand Down

0 comments on commit dbf760d

Please sign in to comment.