notjack
2019-12-21 10:02:18

Just making sure there isn’t some small-list optimization or something


mflatt
2019-12-21 13:13:58

There’s no small-list optimization.


jubnzv
2019-12-21 14:52:45

@jubnzv has joined the channel


howestim
2019-12-21 17:45:49

@howestim has joined the channel


mavc
2019-12-21 18:30:48

@mavc has joined the channel


elyandarin
2019-12-22 00:27:54

@sorawee Thanks! There isn’t a list equivalent to appending "" to a string, then, though?


sorawee
2019-12-22 00:29:40

What do you mean by that? You can do append , right?

> (append (list 1) (list 2 3 4)) '(1 2 3 4) > (append (list) (list 2 3 4)) '(2 3 4)


elyandarin
2019-12-22 00:37:56

Ah, OK, so it is possible then. and I just shouldn’t have used cons.


elyandarin
2019-12-22 00:38:01

Thanks


elyandarin
2019-12-22 00:40:20

I worry sometimes when I play around with a new language to see what works, that I’m teaching myself “no, that approach doesn’t work” when really I just overlooked some basic error I made.


elyandarin
2019-12-22 00:42:17

New question: Is there a good way to access internally defined functions? Like, for unit-testing, mostly.


sorawee
2019-12-22 00:43:10

By internally defined, you mean a function defined inside a function? Pretty sure the answer is no.


elyandarin
2019-12-22 00:43:24

yeah


sorawee
2019-12-22 00:43:25

You can lambda-lift the function out, and then test it outside


sorawee
2019-12-22 00:44:26

elyandarin
2019-12-22 00:45:23

Thanks, I’ll check it out!


elyandarin
2019-12-22 00:51:12

Wow, that’s a lot of equations.


elyandarin
2019-12-22 00:53:08

Is this, like, a programming technique, that they’re defining stringently to help in complicated cases, or does it detail how to program a function to automate your lambda-lifting for you?


sorawee
2019-12-22 00:56:59

For your use case, you might think of this as a kind of refactoring


elyandarin
2019-12-22 00:57:01

I haven’t gotten into macros yet, but I could see there being a macro that takes a function name as input and then lambda-lifts its internally defined functions into the public scope.


sorawee
2019-12-22 00:58:43

(define (f x) (define (g y) (+ x y) (g (+ 1 x)))) is converted to

(define (f x) (define (g x* y) (+ x* y) (g x (+ 1 x)))) and then converted to

(define (g x* y) (+ x* y) (define (f x) (g x (+ 1 x))))


elyandarin
2019-12-22 01:01:22

I tend to define internal functions like the second case anyway, so actually lifting them out is easy; I just put them inside the functions where they’re used because I feel it’s tidier that way, and gives a better overview of the code.


elyandarin
2019-12-22 01:03:13

I already lifted it out so I could unit-test it, but for aesthetic reasons, I’d like to put it back in and still be able to test it.


elyandarin
2019-12-22 01:08:07

Eh, I guess it’s just one more item added on the pile of things I want to be able to do in the language I’m making…


sorawee
2019-12-22 01:30:22

That’s what module system is for


sorawee
2019-12-22 01:31:28

You can restrict what a module will export, so use that as a way to tidy your program.