dmitryhertz
2018-3-17 08:38:49

¡Hola a todos! I need help…


dmitryhertz
2018-3-17 08:40:00

Is it possible to write a (let loop (…) …) form that is able to return (values …) instead of (list …) ?


lexi.lambda
2018-3-17 08:49:53

Yes.


dmitryhertz
2018-3-17 08:53:08

Great! Should I use (let-values loop (…) …) form instead of (let loop (…) …) ?


lexi.lambda
2018-3-17 08:53:55

No, you can just use (let loop (....) ....). Named let is just sugar for a lambda that is immediately invoked.


dmitryhertz
2018-3-17 08:56:11

I’m going to figure out


dmitryhertz
2018-3-17 09:14:39

So, I cannot. ( Is there any example of this?


zenspider
2018-3-17 09:19:13

@dmitryhertz what have you tried? what is not working for you?


dmitryhertz
2018-3-17 09:32:58

dmitryhertz
2018-3-17 09:40:04

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


dmitryhertz
2018-3-17 09:41:30

So currently I just use a simple form that returns entries and then another function just counts their number.


zenspider
2018-3-17 09:47:55

you said you wanted to return with values but now you’re talking about recursing/looping with values


zenspider
2018-3-17 09:49:00

I’m not sure I understand


zenspider
2018-3-17 09:52:06

example: (let loop ((x 3)) (if (zero? x) (values 'a 'b 'c) (loop (sub1 x))))


dmitryhertz
2018-3-17 09:54:40

> 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.


dmitryhertz
2018-3-17 09:56:59

@zenspider yes, your example helped me to understand that I did something wrong.


zenspider
2018-3-17 09:57:15

cool. glad to help.


zenspider
2018-3-17 09:57:19

goes to bed


dmitryhertz
2018-3-17 09:57:35

Good night!


jerome.martin.dev
2018-3-17 11:32:56

Thanks a lot!


jerome.martin.dev
2018-3-17 12:36:34

That way I only have one syntax-parse clause for everything, and I don’t need a helper function, which makes everything wayyy simpler.


sorawee
2018-3-18 03:15:18

It’s racket/set! (I just discovered that it is the sole bottleneck)