Add for*/sum: and for*/product: to TR.

These currently don't play nice with inference, so they only work in
limited cases.

original commit: 5b22dfb6b0d329af5c2cd78a1652431de29fe739
This commit is contained in:
Vincent St-Amour 2011-07-27 16:45:59 -04:00
parent fea766dfbb
commit c3a9c07979
3 changed files with 23 additions and 1 deletions

View File

@ -142,3 +142,21 @@
[j : Integer (in-range 1 10)])
(+ i j))
185794560)
;; multiclause versions of these don't currently work properly
(check =
(for*/sum: : Integer
([i : Integer (in-range 10)])
i)
45)
(check =
(for*/product: : Integer
([i : Integer (in-range 10)])
i)
0)
(check =
(for*/product: : Integer
([i : Integer (in-range 1 10)])
i)
362880)

View File

@ -759,7 +759,9 @@ This file defines two sorts of primitives. All of them are provided into any mod
(for*/first: for*/first)
(for*/last: for*/last)
(for*/vector: for*/vector)
(for*/flvector: for*/flvector))
(for*/flvector: for*/flvector)
(for*/sum: for*/sum)
(for*/product: for*/product))
;; Like for/lists: and for/fold:, the inferencer can handle these correctly.
(define-syntax (for*/lists: stx)

View File

@ -159,6 +159,8 @@ variants.
@defform[(for*/or: type-ann-maybe (for:-clause ...) expr ...+)]
@defform[(for*/first: type-ann-maybe (for:-clause ...) expr ...+)]
@defform[(for*/last: type-ann-maybe (for:-clause ...) expr ...+)]
@defform[(for*/sum: type-ann-maybe (for:-clause ...) expr ...+)]
@defform[(for*/product: type-ann-maybe (for:-clause ...) expr ...+)]
]]{
These behave like their non-annotated counterparts, with the exception
that @racket[#:when] clauses can only appear as the last