【文件属性】:
文件名称:patmat:原始JavaScript中的模式匹配
文件大小:25KB
文件格式:ZIP
更新时间:2021-05-16 22:29:47
JavaScript
帕特玛
原始JavaScript中的模式匹配
该软件包的灵感来自。 以下是该文章中的一些示例,可用于演示功能。
阶乘
const { $ , match } = require ( "@bakerface/patmat" ) ;
const factorial = match ( [
[ 0 , ( ) => 1 ] ,
[ $ , n => n * factorial ( n - 1 ) ]
] ) ;
console . log ( factorial ( 5 ) ) ; // 120
二叉树
const { $ , _ , type , match } = require ( "@bakerface/patmat" ) ;
const nil = type ( ) ;
const node = type ( t => [ Number , t , t ] ) ;
cons
【文件预览】:
patmat-master
----.gitignore(914B)
----.eslintrc(323B)
----package.json(1019B)
----package-lock.json(125KB)
----src()
--------index.js(3KB)
----LICENSE(1KB)
----index.js(35B)
----README.md(1KB)