Created
June 17, 2017 15:57
-
-
Save polidog/3c620b33d5c494cc8293683f410ef498 to your computer and use it in GitHub Desktop.
このコードが理解できない・・・
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
var empty = () => { | |
return (pattern) => { | |
return pattern.empty() | |
} | |
} | |
var cons = (value, list) => { | |
return (pattern) => { | |
return pattern.cons(value,list) | |
} | |
} | |
var match = (data, pattern) => { | |
return data(pattern) | |
} | |
var isEmpty = (alist) => { | |
return match(alist,{ | |
empty: (_) => { | |
return true; | |
}, | |
cons: (head, tail) => { | |
return false; | |
} | |
}) | |
} | |
console.log(isEmpty(empty())) | |
console.log(isEmpty(cons(1,empty()))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
型がないと辛い問題・・・