This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 漢字で表した整数を整数の数値として返す | |
const kanToNum = (knum="三百二十一")=>{ | |
const or=(a,b)=>a==null ? b : a; | |
const numb = new Map() | |
.set("零",0).set("一",1).set("二",2).set("三",3).set("四",4) | |
.set("五",5).set("六",6).set("七",7).set("八",8).set("九",9); | |
const places = new Map() | |
.set("十",10).set("百",100).set("千",1000).set("万",10000) | |
.set("億",10**8).set("兆",10**12).set("京",10**16).set("垓",10**20); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const calc=((raw)=>{ | |
let s=[] | |
const sw = (addIndex,v,f)=>new class { | |
cases=new Map(); | |
def=null; | |
c(v,f){ | |
this.cases.set(v,f) | |
return this | |
} | |
d(f){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*MIT License | |
Copyright 2022 ikasoba | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE US |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const calc=((raw)=>{ | |
const sw = (addIndex,v,f)=>new class { | |
cases=new Map(); | |
def=null; | |
c(v,f){ | |
this.cases.set(v,f) | |
return this | |
} | |
d(f){ | |
this.def=f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const genCharsFromAToB=(a,b)=>Array.from({length:b.charCodeAt(0)-a.charCodeAt(0)+1},(_,i)=>String.fromCharCode(a.charCodeAt(0)+i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @return {any|null|undefined} | |
* @example | |
* getProperty( | |
* "posts[0].content", | |
* { | |
* posts:[ | |
* { | |
* content:"hogehoge" | |
* } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const range = (i=0)=>[i,...([()=>range(i-1),()=>[]][~~(i<=0)]())] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Append<T extends any[],U extends any> = [...T,U] | |
type range<N extends number,A extends any[]> = { | |
0:range<N,Append<A,A["length"]>>, | |
1:A | |
}[A["length"] extends N ? 1 : 0] | |
const nums:range<4,[]>=[0,1,2,3] | |
console.log(nums) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Down<A> = A extends [null, ...null[]] | |
? ((..._: A) => null) extends (_:null, ...a:infer T) => null | |
? T | |
: never | |
: never | |
export type Up<A extends null[],B extends null|null[] = null> = [...A,...(B extends null ? [B] : B)] | |
export type Num<N extends number,A extends null[] = []> = { | |
0:A, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.from({length:500},(_,n)=>((i=n+1)=>(i%3==0) + (i%15==0) + (i%5==0)*2)()).map((x,i)=>x&1 ? "Fizz" : x&2 ? "Buzz" : x&4 ? "Fizz Buzz" : i+1).forEach((m)=>console.log(m)) |
OlderNewer