coffee-js / languages

编程语言学习论坛
https://github.com/coffee-js/languages/issues
112 stars 11 forks source link

模式匹配范围比较实现方法 #29

Open ghost opened 11 years ago

ghost commented 11 years ago

发现了这个:Unlike in Haskell, changing the order of the clauses would not change the meaning of the program, because Hope's pattern matching always favors more specific patterns over less specific ones. (https://en.wikipedia.org/wiki/Hope_programming_language ) 问题是怎么判别“ favors more specific patterns over less specific ones”,当我试图实现这个时就发现没原来想的那么简单。 所以暂时还是用Haskell式的以顺序匹配。 有什么办法么?

ghost commented 11 years ago

https://gist.github.com/4212705 @skydark 的方法