!! 测试新的 util 库 !! 导入 util 库 @util; show(`=== 测试 util 库函数 ===`); !! 随机数函数 show(`\n随机数: `, util.random()); show(`随机整数 (1-100): `, util.randint(`1`, `100`)); !! 数学函数 show(`\n绝对值: `, util.abs(`-123`)); show(`四舍五入: `, util.round(`3.14159`, `2`)); show(`最小值: `, util.min(`10`, `5`, `20`)); show(`最大值: `, util.max(`10`, `5`, `20`)); show(`求和: `, util.sum(`1`, `2`, `3`, `4`, `5`)); show(`平均值: `, util.average(`10`, `20`, `30`)); !! 类型检查函数 show(`\n类型检查:`); show(`是否是数字: `, util.isNumber(`123`)); show(`是否是数字: `, util.isNumber(`abc`)); show(`是否是字符串: `, util.isString(`hello`)); show(`是否是数组: `, util.isArray(`[1,2,3]`)); !! 类型转换函数 show(`\n类型转换:`); show(`转为数字: `, util.toNumber(`123`)); show(`转为字符串: `, util.toString(`123`)); !! 类型判断函数 show(`\n类型判断:`); show(`类型: `, util.typeof(`123`)); show(`类型: `, util.typeof(`hello`)); show(`类型: `, util.typeof(`[1,2,3]`));