Questions tagged «recursive-type»

2
处理递归和类型时如何减少代码重复
我目前正在为一种编程语言开发一个简单的解释器,并且我的数据类型如下: data Expr = Variable String | Number Int | Add [Expr] | Sub Expr Expr 我有许多函数可以执行简单的操作,例如: -- Substitute a value for a variable substituteName :: String -> Int -> Expr -> Expr substituteName name newValue = go where go (Variable x) | x == name = Number newValue go …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.