It might be worth noting that ret was unnecessary in this case.
(mac ret (var val . body)
`(let ,var ,val ,@body ,var))
(def question (url q a b c d)
(let id (++ question-id*)
(ret new (inst 'question
'id id 'url (video-url url)
'q q 'a a 'b b 'c c 'd d)
(= (questions* id) new))))
could just be
(def question (url q a b c d)
(let id (++ question-id*)
(= (questions* id)
(inst 'question
'id id 'url (video-url url)
'q q 'a a 'b b 'c c 'd d))))
ret would certainly be useful in general, of course.
I agree that 'ret would be more useful in other areas than here. In arc.arc 'best, 'summing, 'sum, 'listtab, 'copy, 'inst, 'w/table, 'memtable, and 'evtil all use this idiom of creating a local variable with 'let and then returning it.
Thanks for the feedback. I'll take a look at how rand-choice and pull can improve shuffle and choices.
I use between alot with numbers and would like a similar utility for strings, but I understand its confusing that the arguments to between work exclusively with strings but inclusively with numbers.
param is just mapping over a paired list. Infinite recursion shouldn't be a problem.
There's a call to param inside param's body. Isn't it the same fn? Ah, it's just the tag macro's private language.
between with a string == substring between delimiters.
between without a string == pick a random number in a range.
Is that right? It's not just about exclusive/inclusive, that's pretty different semantics.
I meant that the return value of the string version doesn't include the delimiters (between "ab" "ef" "abcdef"), while when something like (between 3 7) is called, the return value could also be 3 or 7.
Maybe it would make more sense to modify rand so that it could return numbers in a range if given 2 arguments.