kzccm1d4if10m2xaz1wqy3xar821pp1r-my-site-anaphoric-git.test.suzanne.soy-0.0.1

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 8cec548ea745ef8f6c2f69c75de189283e98f1d5
parent affa5e15a0e8dd488b835a77332d3d09bca3b03a
Author: AlexKnauth <alexander@knauth.org>
Date:   Thu, 25 Jan 2018 22:47:34 -0500

add and-let

Diffstat:
Aand-let.rkt | 13+++++++++++++
Mmain.rkt | 6++++--
Mscribblings/anaphoric.scrbl | 15+++++++++++++--
3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/and-let.rkt b/and-let.rkt @@ -0,0 +1,13 @@ +#lang racket/base + +(provide and-let) + +(require syntax/parse/define "if-let.rkt" (for-syntax racket/base)) + +(define-syntax and-let + (syntax-parser + [(_) #'#true] + [(_ body:expr) #'body] + [(_ [variable:id condition:expr] rest ...+) + #'(if-let [variable condition] (and-let rest ...) #false)])) + diff --git a/main.rkt b/main.rkt @@ -16,7 +16,8 @@ anaphoric/acond anaphoric/if-let anaphoric/when-let - anaphoric/cond-let)) + anaphoric/cond-let + anaphoric/and-let)) (require anaphoric/it anaphoric/aif @@ -24,4 +25,5 @@ anaphoric/acond anaphoric/if-let anaphoric/when-let - anaphoric/cond-let) + anaphoric/cond-let + anaphoric/and-let) diff --git a/scribblings/anaphoric.scrbl b/scribblings/anaphoric.scrbl @@ -122,4 +122,16 @@ using @racket[it]. Each @racket[conditionᵢ] is evaluated at most once (evaluation stops at the first successful - @racket[conditionᵢ]).} -\ No newline at end of file + @racket[conditionᵢ]).} + +@defform[(and-let [identifier condition] ... body)]{ + Variant of @racket[and] which binds each @racket[identifier] + to the value of its @racket[condition], in scope within all + @racket[condition]s afterwards as well as in @racket[body]. + + Each @racket[condition] is evaluated at most once, and + evaluation stops at the first false condition. The + @racket[body] is only evaluated when all + @racket[conditions] are successful. +} +