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

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

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -