haskell - 等效于 Haskell where 子句的方案

标签 haskell scheme racket

我只是在学习计划,但我希望能够少重复自己。

有没有办法可以为本地范围内的子表达式分配名称?

根据评论:

Haskell where 子句

x = s * t 
  where s = 10
        t = 20

在这种情况下,x 应该是 200。

最佳答案

Let(或 letrec 用于递归绑定(bind)),例如:

(define (f g) 
  (let ((x 1) (y (* g 2))) 
       (+ x y)))

关于haskell - 等效于 Haskell where 子句的方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1451677/

相关文章:

haskell - 过滤统一列表的列表

haskell - 如何实现 index-core 风格的索引状态单子(monad)?

lisp - 如何编写一个接受两个列表并返回四个列表的方案函数

functional-programming - 我需要怎么做才能获得付款?

haskell - 使用 ghci 时如何重用 cabal 编译模块

list - 当列表参数有多个元素时 Haskell 出错

scheme - 方案: define-syntax-rule pattern matching syntax

scheme - 如何评估从 Scheme 中的函数返回的符号?

oop - python 的 __repr__ 和 __str__ 的 Racket 等价物?

scheme - 句子输出是垂直的,每个单词之间有换行符