zenspider
2017-7-4 21:54:59

hey. I made a thing to make profiling load times easier to figure out: https://gist.github.com/d31e7d54e8350370b141393f4afc24d6


zenspider
2017-7-4 21:55:09

zenspider
2017-7-4 21:55:17

I’ll port to racket later


guannanwei
2017-7-4 22:04:26

is there anyway to catch a (values x y ...) as a whole when passing it to a function?


zenspider
2017-7-4 22:16:32

@guannanwei ? can you explain?


guannanwei
2017-7-4 22:19:30

for example, I have a function f and it takes one argument, when applying (values ...) to f, I would like to use (values ...) as a single variable inside of f



zenspider
2017-7-4 22:20:23

(call-with-values (thunk (values 1 2 3)) list) ; ‘(1 2 3)


zenspider
2017-7-4 22:20:55

but… I don’t think you can make a function that takes a variable number of values… hence the thunk


guannanwei
2017-7-4 22:20:57

I do found call-with-values but it restricts me to put values inside of lambda, I’m just looking for a more elegant way to do this


zenspider
2017-7-4 22:21:35

@guannanwei why do you want to apply values as an arg? can you explain what you’re trying to do?


zenspider
2017-7-4 22:23:47

> It is impossible to bind the evaluated result of values expression to a single variable unlike other Scheme expressions

http://docs.racket-lang.org/srfi/srfi-86.html

Might want to check out mu/nu from 86


zenspider
2017-7-4 22:23:52

they look interesting


guannanwei
2017-7-4 22:24:04

Well, I have a function that returns values, I would like to compare the results of two applications of that function. Probably macro could do that?


zenspider
2017-7-4 22:24:40
(define v (values 1 2 3))		=> error
(define v (lambda () (values 1 2 3)))	=> (lambda () (values 1 2 3))
(define m (mu 1 2 3))			=> (lambda (f) (f 1 2 3))
(define a (apply values 1 '(2 3)))	=> error
(define a
  (lambda () (apply values 1 '(2 3))))	=> (lambda () (apply values 1 '(2 3)))
(define n (nu 1 '(2 3)))		=> (lambda (f) (apply f 1 '(2 3)))

(call-with-values v list)	=> (1 2 3)
(m list)			=> (1 2 3)
(call-with-values a list)	=> (1 2 3)
(n list)			=> (1 2 3)

zenspider
2017-7-4 22:25:36

so for testing? yeah… you could do that with a macro. wrap up LHS and RHS with call-with-values … list


zenspider
2017-7-4 22:25:48

then use check-equal?


guannanwei
2017-7-4 22:26:42

yeah, for testing, right, for now I just put values into a lambda and use nested call-with-values, then I could compare the equality of two lists


guannanwei
2017-7-4 22:27:36

@zenspider anyway, SRFI–86 looks helpful, thank you!