racket - How to convert a list into xexpr? -


#lang racket (struct result (q) #:mutable)  (define result (result '()))  (define (insert-result! result val)   (set-result-q! result (cons val (result-q result))))  (insert-result! result "hello") (insert-result! result "wrold") (print (result-q result))  (define (iter l) `(div ((class "result"))     ,(for ([i (result-q l)])       `(p ,i))))  (iter result) 

i'm trying xexpr. result should '("wrold" "hello") after code run. in iter function want produce output:

'(div ((class "result")) (p "world") (p "hello"))

somehow code above gives me '(div ((class "result")) #<void>) instead. how fix issue?

you should use:

,@(for/list ([i (result-q l)])     `(p ,i)) 

notice use of ,@ splicing unquote, for/list collecting results list.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -