方案语法:*在列表中?

时间:2013-02-27 05:47:30

标签: syntax scheme

我是Scheme的新手。有人可以解释一下*在以下代码中的作用吗?

(define pat2 '(or
           (list a g t a t a t g g a t a)
           (list g t a g g c c g t)
           (list c c c g a t a a a a a a g t g t c g t)
           (list c g a t c c c (junk 1) c g a t c t a)))
(define pat3 (list 'list pat2 '(junk 2)))
(define pat4 (list '* pat3))  ; I'm confused about the * here.

我知道pat4的内容类似于

(*
  (list
  (or (list a g t a t a t g g a t a)
  (list g t a g g c c g t)
  (list c c c g a t a a a a a a g t g t c g t)
  (list c g a t c c c (junk 1) c g a t c t a))
  (junk 2)))

但是我仍然对*是什么感到困惑...它通常意味着乘法,但它不可能是因为它可以吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

它只是符号*(这就是它引用的原因;报价会阻止对符号进行评估)。

如果你执行你的代码,你会发现pat4只是前面带*符号的pat3:

> pat2
'(or (list a g t a t a t g g a t a) (list g t a g g c c g t) (list c c c g a t a a a a a a g t g t c g t) (list c g a t c c c (junk 1) c g a t c t a))
> pat3
'(list (or (list a g t a t a t g g a t a) (list g t a g g c c g t) (list c c c g a t a a a a a a g t g t c g t) (list c g a t c c c (junk 1) c g a t c t a)) (junk 2))
> pat4
'(* (list (or (list a g t a t a t g g a t a) (list g t a g g c c g t) (list c c c g a t a a a a a a g t g t c g t) (list c g a t c c c (junk 1) c g a t c t a)) (junk 2)))