Skip to content

添加数学便利工具扩展 - #323

Open
3DJonas wants to merge 4 commits into
Gandi-IDE:mainfrom
3DJonas:main
Open

添加数学便利工具扩展#323
3DJonas wants to merge 4 commits into
Gandi-IDE:mainfrom
3DJonas:main

Conversation

@3DJonas

@3DJonas 3DJonas commented Jun 19, 2026

Copy link
Copy Markdown

提供数学计算、字符串处理、数组操作、几何计算等100多个积木

@3DJonas

3DJonas commented Jun 19, 2026

Copy link
Copy Markdown
Author

增加更多代码!代码数量已经突破150+!

@3DJonas

3DJonas commented Jun 20, 2026

Copy link
Copy Markdown
Author

请求审核通过!不会卡作品!不要有问题!(这只是个便利扩展QWQ)

这是真的!我测试过!我的CCW ID是272003660 awa

@3DJonas 3DJonas left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我感觉大家的建议有点少( ̄_, ̄ )

@3DJonas

3DJonas commented Jun 24, 2026

Copy link
Copy Markdown
Author

你好,这个 PR 是为了在素材集市发布扩展。请问审核进度如何?有需要我修改的地方吗?谢谢!

@BenPaoDeXiaoZhi

Copy link
Copy Markdown

数学功能原版scratch和七星松的数据分析扩展中大部分能实现,字符串功能也是七星松的字符串处理有

@BenPaoDeXiaoZhi

Copy link
Copy Markdown

数组功能七星松的变量数组扩展也有

@BenPaoDeXiaoZhi

Copy link
Copy Markdown

而且强烈不推荐使用中文作为函数和i18n key,显得很“初学者”

@BenPaoDeXiaoZhi

Copy link
Copy Markdown

同时这是官方approved的扩展库,扩展集市的审核不需要在这里pr

'四舍五入': 'round [数] to [小数位数] decimals',
'最大值': 'max [数1] and [数2]',
'最小值': 'min [数1] and [数2]',
'拼接': 'concat [文本1] and [文本2]',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此功能原版已有

'分割': 'split [文本] by [分隔符] (JSON)',
'分割转列表': 'split [文本] by [分隔符] (JSON)',
'分割行': 'split lines [文本] (JSON)',
'包含': '[文本] contains [子文本]?',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此功能原版可实现

Comment on lines +277 to +396
this['平方'] = this._平方.bind(this);
this['平方根'] = this._平方根.bind(this);
this['绝对值'] = this._绝对值.bind(this);
this['取余'] = this._取余.bind(this);
this['幂运算'] = this._幂运算.bind(this);
this['立方'] = this._立方.bind(this);
this['立方根'] = this._立方根.bind(this);
this['正弦'] = this._正弦.bind(this);
this['余弦'] = this._余弦.bind(this);
this['正切'] = this._正切.bind(this);
this['对数'] = this._对数.bind(this);
this['取整'] = this._取整.bind(this);
this['向上取整'] = this._向上取整.bind(this);
this['四舍五入'] = this._四舍五入.bind(this);
this['最大值'] = this._最大值.bind(this);
this['最小值'] = this._最小值.bind(this);
this['拼接'] = this._拼接.bind(this);
this['长度'] = this._长度.bind(this);
this['截取'] = this._截取.bind(this);
this['替换'] = this._替换.bind(this);
this['替换一次'] = this._替换一次.bind(this);
this['查找'] = this._查找.bind(this);
this['反向查找'] = this._反向查找.bind(this);
this['出现次数'] = this._出现次数.bind(this);
this['转大写'] = this._转大写.bind(this);
this['转小写'] = this._转小写.bind(this);
this['大小写互换'] = this._大小写互换.bind(this);
this['首字母大写'] = this._首字母大写.bind(this);
this['单词首字母大写'] = this._单词首字母大写.bind(this);
this['去首尾空格'] = this._去首尾空格.bind(this);
this['去左空格'] = this._去左空格.bind(this);
this['去右空格'] = this._去右空格.bind(this);
this['去所有空格'] = this._去所有空格.bind(this);
this['去指定字符'] = this._去指定字符.bind(this);
this['分割'] = this._分割.bind(this);
this['分割转列表'] = this._分割转列表.bind(this);
this['分割行'] = this._分割行.bind(this);
this['包含'] = this._包含.bind(this);
this['开头是'] = this._开头是.bind(this);
this['结尾是'] = this._结尾是.bind(this);
this['是全数字'] = this._是全数字.bind(this);
this['是全字母'] = this._是全字母.bind(this);
this['是全大写'] = this._是全大写.bind(this);
this['是全小写'] = this._是全小写.bind(this);
this['是全空格'] = this._是全空格.bind(this);
this['反转'] = this._反转.bind(this);
this['重复'] = this._重复.bind(this);
this['截取前'] = this._截取前.bind(this);
this['截取后'] = this._截取后.bind(this);
this['左对齐'] = this._左对齐.bind(this);
this['右对齐'] = this._右对齐.bind(this);
this['居中对齐'] = this._居中对齐.bind(this);
this['提取数字'] = this._提取数字.bind(this);
this['提取字母'] = this._提取字母.bind(this);
this['提取中文'] = this._提取中文.bind(this);
this['比较文本'] = this._比较文本.bind(this);
this['比较文本不区分大小写'] = this._比较文本不区分大小写.bind(this);
this['替换多行'] = this._替换多行.bind(this);
this['去除换行'] = this._去除换行.bind(this);
this['MD5加密'] = this._MD5加密.bind(this);
this['Base64编码'] = this._Base64编码.bind(this);
this['Base64解码'] = this._Base64解码.bind(this);
this['创建数组'] = this._创建数组.bind(this);
this['创建数组转列表'] = this._创建数组转列表.bind(this);
this['数组长度'] = this._数组长度.bind(this);
this['添加元素'] = this._添加元素.bind(this);
this['插入元素'] = this._插入元素.bind(this);
this['删除元素'] = this._删除元素.bind(this);
this['删除指定元素'] = this._删除指定元素.bind(this);
this['获取元素'] = this._获取元素.bind(this);
this['获取第一个元素'] = this._获取第一个元素.bind(this);
this['获取最后一个元素'] = this._获取最后一个元素.bind(this);
this['修改元素'] = this._修改元素.bind(this);
this['查找元素'] = this._查找元素.bind(this);
this['数组包含'] = this._数组包含.bind(this);
this['反转数组'] = this._反转数组.bind(this);
this['排序数组'] = this._排序数组.bind(this);
this['降序排序数组'] = this._降序排序数组.bind(this);
this['拼接数组'] = this._拼接数组.bind(this);
this['清空数组'] = this._清空数组.bind(this);
this['连接数组'] = this._连接数组.bind(this);
this['数组去重'] = this._数组去重.bind(this);
this['数组切片'] = this._数组切片.bind(this);
this['勾股求弦'] = this._勾股求弦.bind(this);
this['弦勾求股'] = this._弦勾求股.bind(this);
this['弦股求勾'] = this._弦股求勾.bind(this);
this['直角三角形面积'] = this._直角三角形面积.bind(this);
this['三角形周长'] = this._三角形周长.bind(this);
this['三角形面积'] = this._三角形面积.bind(this);
this['圆周长'] = this._圆周长.bind(this);
this['圆面积'] = this._圆面积.bind(this);
this['矩形面积'] = this._矩形面积.bind(this);
this['矩形周长'] = this._矩形周长.bind(this);
this['正方形面积'] = this._正方形面积.bind(this);
this['正方形周长'] = this._正方形周长.bind(this);
this['数组求和'] = this._数组求和.bind(this);
this['数组平均值'] = this._数组平均值.bind(this);
this['数组最大值'] = this._数组最大值.bind(this);
this['数组最小值'] = this._数组最小值.bind(this);
this['数组中位数'] = this._数组中位数.bind(this);
this['随机整数'] = this._随机整数.bind(this);
this['随机小数'] = this._随机小数.bind(this);
this['随机选择'] = this._随机选择.bind(this);
this['随机打乱数组'] = this._随机打乱数组.bind(this);
this['随机布尔'] = this._随机布尔.bind(this);
this['随机字母'] = this._随机字母.bind(this);
this['随机数字'] = this._随机数字.bind(this);
this['随机字符串'] = this._随机字符串.bind(this);
this['是偶数'] = this._是偶数.bind(this);
this['是奇数'] = this._是奇数.bind(this);
this['是正数'] = this._是正数.bind(this);
this['是负数'] = this._是负数.bind(this);
this['是零'] = this._是零.bind(this);
this['是直角三角形'] = this._是直角三角形.bind(this);
this['是等腰三角形'] = this._是等腰三角形.bind(this);
this['是等边三角形'] = this._是等边三角形.bind(this);
this['是数组'] = this._是数组.bind(this);
this['是文本'] = this._是文本.bind(this);
this['是数字'] = this._是数字.bind(this);
this['是布尔'] = this._是布尔.bind(this);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没必要bind,1.你的func没有用this
2.gandi调用func时自己就有bind

Comment on lines +401 to +404
_平方(args) { const x = toNumber(args.数); return isNaN(x) ? NaN : x*x; }
_平方根(args) { const x = toNumber(args.数); return (isNaN(x) || x < 0) ? NaN : Math.sqrt(x); }
_绝对值(args) { const x = toNumber(args.数); return isNaN(x) ? NaN : Math.abs(x); }
_取余(args) { const a = toNumber(args.数), b = toNumber(args.除数); return (isNaN(a) || isNaN(b) || b === 0) ? NaN : ((a % b) + b) % b; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也是原版有的

Comment on lines +412 to +414
_取整(args) { const x = toNumber(args.数); return isNaN(x) ? NaN : Math.floor(x); }
_向上取整(args) { const x = toNumber(args.数); return isNaN(x) ? NaN : Math.ceil(x); }
_四舍五入(args) { const x = toNumber(args.数), d = Math.floor(toNumber(args.小数位数)); if (isNaN(x) || isNaN(d) || d < 0) return NaN; const factor = Math.pow(10, d); return Math.round(x * factor) / factor; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Comment on lines +408 to +410
_正弦(args) { const deg = toNumber(args.角度); return isNaN(deg) ? NaN : Math.sin(deg * Math.PI / 180); }
_余弦(args) { const deg = toNumber(args.角度); return isNaN(deg) ? NaN : Math.cos(deg * Math.PI / 180); }
_正切(args) { const deg = toNumber(args.角度); return isNaN(deg) ? NaN : Math.tan(deg * Math.PI / 180); }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

const hash = require('crypto').createHash('md5').update(s).digest('hex');
return hash;
} catch(e) {
// 降级方案:使用第三方MD5简单实现(这里省略,若需要可加入一个纯JS MD5)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

方案呢?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

正在修改QWQ

请求审核通过

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

重复功能很多,估计不会通过

@sylarhcn

sylarhcn commented Jul 3, 2026 via email

Copy link
Copy Markdown
Contributor

@3DJonas

3DJonas commented Jul 7, 2026 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants