On Thursday, February 11, 2016 at 9:08:33 AM UTC-8, Matthew Butterick wrote:

> I'm supposing you know that Racket has at least two native representations 
> (X-expression and SXML) for HTML-like structures, so hacking HTML tags by 
> hand is unnecessary.

Yes, thank you for mentioning them. I was actually thinking of starting with 
SXML, but then turning it into a list of string fragments (with spaces left for 
the dynamically generated parts) as a simplification step once I've figured out 
where everything goes. But there are other languages besides HTML this is 
relevant for.

(define (query condA condB (limit #f) (offset #f))
  (list "SELECT something FROM table WHERE "
                condA
                " AND "
                condB
                (if limit
                        (list "LIMIT " limit
                                  (if offset
                                          (list "OFFSET " offset)
                                          '()))
                        '())))

for instance.

> But if you must, there's a #lang for that:

I'll look at scribble/text, but I don't think a whole new language is necessary 
just to factor if-statements inside out. I suspect it does a (flatten) 
operation though, after having constructed a complex tree, since this problem 
seems like a difficult one, and (flatten) really isn't all that much trouble. I 
was just curious if it was possible to do this, but if I had to get 
scribble/text ready to release to the masses I'd just throw a (flatten) in 
there to splice the lists.

> Enjoy.

No problem!

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to