Are there any purely functional Schemes or Lisps?

前端 未结 9 1188
不知归路
不知归路 2020-12-24 07:10

I\'ve played around with a few functional programming languages and really enjoy the s-expr syntax used by Lisps (Scheme in particular).

I also see the advantages of

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-24 07:46

    If you like lisp's syntax then you can actually do similar things in Haskell

    let fibs = ((++) [1, 1] (zipWith (+) fibs (tail fibs)))
    

    The let fibs = aside. You can always use s-expr syntax in Haskell expressions. This is because you can always add parentheses on the outside and it won't matter. This is the same code without redundant parentheses:

    let fibs = (++) [1, 1] (zipWith (+) fibs (tail fibs))
    

    And here it is in "typical" Haskell style:

    let fibs = [1, 1] ++ zipWith (+) fibs (tail fibs)
    

提交回复
热议问题