¡Hola a todos! I need help…
Is it possible to write a (let loop (…) …) form that is able to return (values …) instead of (list …) ?
Yes.
Great! Should I use (let-values loop (…) …) form instead of (let loop (…) …) ?
No, you can just use (let loop (....) ....)
. Named let
is just sugar for a lambda that is immediately invoked.
I’m going to figure out
So, I cannot. ( Is there any example of this?
@dmitryhertz what have you tried? what is not working for you?
I’d like to return an entry-list and the number of entries using (values …). Currently I receive the next form (list (entry …) … i), but I need the next one (values v i) or at least (list (list (entry …)) i)
I tried to wrap the cons expression by (values …) but I get an error:
; result arity mismatch; ; expected number of values not received ; expected: 1 ; received: 2
So currently I just use a simple form that returns entries and then another function just counts their number.
you said you wanted to return with values
but now you’re talking about recursing/looping with values
…
I’m not sure I understand
example: (let loop ((x 3)) (if (zero? x) (values 'a 'b 'c) (loop (sub1 x))))
> but now you’re talking about recursing/looping with values
… Yes, you understood it right. I want to produce a list and a number of the elements of the list at the same time and then return the result as two values by using values
form. Now I made a function that returns the number just as the last element of the list which could have unpredictable number of elements.
@zenspider yes, your example helped me to understand that I did something wrong.
cool. glad to help.
goes to bed
Good night!
Thanks a lot!
That way I only have one syntax-parse clause for everything, and I don’t need a helper function, which makes everything wayyy simpler.
It’s racket/set
! (I just discovered that it is the sole bottleneck)