[racket] Bouncing default value
Hello,
On Sat, Feb 11, 2012 at 14:55, Laurent <laurent.orseau at gmail.com> wrote:
> ...
>
> (define (bar [arg2 (get-default-value foo arg2)])
> (foo 5 arg2))
>
>
>
Maybe someone will have a better idea (or a brighter implementation), but
if not, here's my contribution:
#lang racket
(require rackunit)
(define (foo arg1 [arg2 10])
(+ arg1 arg2))
(define (bar [arg2 #f])
(let ([arg1 5])
(cond
[arg2 (foo arg1 arg2)]
[else (foo arg1)])))
(check-= (bar 2) 7 0)
(check-= (bar) 15 0)
;;;;;;;;;;;;;
I think what Robby wrote seconds ago is compatible with that...
[]'s
Rodolfo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120211/609b7f15/attachment.html>