Add round function

This commit is contained in:
syuilo 2019-12-20 02:09:51 +09:00
parent a91f6e2b95
commit 629452476a
3 changed files with 6 additions and 0 deletions

View File

@ -2200,6 +2200,9 @@ pages:
_mod:
arg1: "A"
arg2: "B"
round: "少数を丸める"
_round:
arg1: "数"
eq: "AとBが同じ"
_eq:
arg1: "A"

View File

@ -162,6 +162,7 @@ export class ASEvaluator {
multiply: (a: number, b: number) => a * b,
divide: (a: number, b: number) => a / b,
mod: (a: number, b: number) => a % b,
round: (a: number) => Math.round(a),
strLen: (a: string) => a.length,
strPick: (a: string, b: number) => a[b - 1],
strReplace: (a: string, b: string, c: string) => a.split(b).join(c),

View File

@ -24,6 +24,7 @@ import {
faExchangeAlt,
faRecycle,
faIndent,
faCalculator,
} from '@fortawesome/free-solid-svg-icons';
import { faFlag } from '@fortawesome/free-regular-svg-icons';
@ -59,6 +60,7 @@ export const funcDefs: Record<string, { in: any[]; out: any; category: string; i
multiply: { in: ['number', 'number'], out: 'number', category: 'operation', icon: faTimes, },
divide: { in: ['number', 'number'], out: 'number', category: 'operation', icon: faDivide, },
mod: { in: ['number', 'number'], out: 'number', category: 'operation', icon: faDivide, },
round: { in: ['number'], out: 'number', category: 'operation', icon: faCalculator, },
eq: { in: [0, 0], out: 'boolean', category: 'comparison', icon: faEquals, },
notEq: { in: [0, 0], out: 'boolean', category: 'comparison', icon: faNotEqual, },
gt: { in: ['number', 'number'], out: 'boolean', category: 'comparison', icon: faGreaterThan, },