If you are OK with preprocessing the argument list into a dictionary, then
you can use keyword-apply/dict
<https://docs.racket-lang.org/reference/dicts.html?q=keyword%2Fapply#%28def._%28%28lib._racket%2Fdict..rkt%29._keyword-apply%2Fdict%29%29>
.

For example:

#lang racket

(require racket/dict)

(define proc (lambda (#:color color #:size size) (display (cons color size))))
(define args '(#:color "red" #:size 3))
(define args*
  (for/hash ([chunk (in-slice 2 args)])
    (values (first chunk) (second chunk))))

(keyword-apply/dict proc args* '())


On Thu, Nov 26, 2020 at 12:53 AM Dimaugh Silvestris <
dimaughsilvest...@gmail.com> wrote:

> Is it possible to reproduce this behavior
> ((lambda (#:color color #:size size) (display (cons color size))) #:color
> "red" #:size 3)
> when what I have is a list such as '(#:color "red" #:size 3) ?
> How can I feed keyword arguments stored in a list as symbols in a way that
> doesn't involve parsing manually?
>
> --
> 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/06a1b45b-77ca-4595-b5b6-0b4ce01fe026n%40googlegroups.com
> <https://groups.google.com/d/msgid/racket-users/06a1b45b-77ca-4595-b5b6-0b4ce01fe026n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CADcuegtRx--ZTxg0sNGb3475Pqb9vw_Hun%2BNp-A76SO8xGg1nQ%40mail.gmail.com.

Reply via email to