Closed oldmankit closed 2 years ago
splitf-txexpr
returns two values — not one list holding two values — so you need to destructure the result with define-values
, let-values
et al.
#lang racket
(require txexpr pollen/template/html rackunit)
(define tx '(div "Wonderful day" (meta "weather" "good") "for a walk"))
(define is-meta? (λ (x) (and (txexpr? x) (equal? 'meta (get-tag x)))))
(define-values (new-tx items-removed) (splitf-txexpr tx is-meta?))
(check-equal? (->html new-tx) "<div>Wonderful dayfor a walk</div>")
(check-equal? (length items-removed) 1)
Thank you! I hadn't properly understand the concept of a "value".
I'm trying to use the splitf-txexpr function but have run into a problem.
From the example:
It returns two lists:
I want to put the first list through
->html
, but trying that gives an arity error. It looks like thesplitf-txexpr
function returns two lists, and->html
will only accept one argument. Surely this must be easy to solve…I tried to get this down to simplest terms, with two lists,
'(1 2) '(3 4)
, and figure out how to get back just the first list. This seems to do it:But when I try that with:
again I get arity mismatch.