I'm quite new to racket, so please pardon me if this is a dumb question.

I'm working my way through the first tutorial in Beautiful Racket 
<https://beautifulracket.com/stacker/intro.html>, and want to extend it. He 
only provides + and * as operators. I added support for others. 

The problem is that I need to specify the operators I support in two 
places, first where they are used in the handle function (see the 
highlighted line)...

(define 
<http://docs.racket-lang.org/reference/define.html#(form._((lib._racket/private/base..rkt)._define))>
 
(handle [arg #f])
  (cond 
<http://docs.racket-lang.org/reference/if.html#(form._((lib._racket/private/letstx-scheme..rkt)._cond))>
   [(number? 
<http://docs.racket-lang.org/reference/number-types.html#(def._((quote._~23~25kernel)._number~3f))>
 
arg) (push-stack! arg)] 
*   [(or 
<http://docs.racket-lang.org/reference/if.html#(form._((lib._racket/private/letstx-scheme..rkt)._or))>
 
(equal? 
<http://docs.racket-lang.org/reference/Equality.html#(def._((quote._~23~25kernel)._equal~3f))>
 
* 
<http://docs.racket-lang.org/reference/generic-numbers.html#(def._((quote._~23~25kernel)._*))>
 
arg) (equal? 
<http://docs.racket-lang.org/reference/Equality.html#(def._((quote._~23~25kernel)._equal~3f))>
 
+ 
<http://docs.racket-lang.org/reference/generic-numbers.html#(def._((quote._~23~25kernel)._+))>
 
arg))*
     (define 
<http://docs.racket-lang.org/reference/define.html#(form._((lib._racket/private/base..rkt)._define))>
 
op-result (arg (pop-stack!) (pop-stack!))) 
     (push-stack! op-result)]))

..and then again when they are provided...

(provide 
<http://docs.racket-lang.org/reference/require.html#(form._((lib._racket/private/base..rkt)._provide))>
 
+ 
<http://docs.racket-lang.org/reference/generic-numbers.html#(def._((quote._~23~25kernel)._+))>
 
* 
<http://docs.racket-lang.org/reference/generic-numbers.html#(def._((quote._~23~25kernel)._*))>
)

I was wondering if it would be possible to specify the supported operators 
in a list...

(define my-funs '(f1 f2))

...which could be used in handle, and then provide the functions in the 
list.

You can't simple do...

(provide my-funs)

...as this is a list of symbols. Equally you can't iterate the list and 
call provide on each member, as provide has to be a top-level function.

So, is there any way to provide the functions in the list?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/b0db39c6-1c57-423f-9386-64ef5c9dc921n%40googlegroups.com.

Reply via email to