laurent.orseau
2022-4-1 09:39:56

laurent.orseau
2022-4-1 09:45:17

I assume it works across processes since it’s based on OS tools apparently, but I just want to make sure


laurent.orseau
2022-4-1 10:07:03

Answering to myself: Yes, it’s cross process. This can be seen with lslocks on Unix at least, with this: #lang racket ;; Only works with Unix (define filename (make-temporary-file "racket_alock~a")) (call-with-file-lock/timeout #f 'exclusive (lambda () (call-with-file-lock/timeout filename 'shared (lambda () (printf "Shouldn't get here\n")) (lambda () (printf "Failed to obtain lock for file\n"))) (define-values (in out) (make-pipe)) (parameterize ([current-output-port out]) (system "lslocks")) (close-output-port out) (for ([line (in-lines in)]) (when (string-contains? line "racket_alock") (displayln "Found lock:") (displayln line))) (displayln 'done)) (lambda () (printf "Shouldn't get here either\n")) #:lock-file (make-lock-file-name filename))


capfredf
2022-4-1 18:39:17

I have a dump question: why isn’t there a list-insert in (racket/list) ?


soegaard2
2022-4-1 18:43:01

Good question. It’s missing from srfi/1 too. Most likely because it is an O(n) operation - and making it available will tempt people to use it :wink:


massung
2022-4-1 18:46:16

As are most list operations in racket/list :wink:


soegaard2
2022-4-1 18:47:40

This one even uses space O(n).


massung
2022-4-1 18:48:28

true


soegaard2
2022-4-1 18:49:19

This leads to: Why is there no standard double linked lists?


massung
2022-4-1 18:51:17

Thank the IBM 704, I guess :wink:


soegaard2
2022-4-1 18:52:22

soegaard2
2022-4-1 18:52:35

I wonder what he is looking for.


massung
2022-4-1 18:53:29

He’s working up the courage to ask her to lunch.


laurent.orseau
2022-4-1 18:54:14

a bug, obviously!


james275
2022-4-1 21:23:30

He’s looking for a moth. Was told to debug his program and …


sschwarzer
2022-4-1 22:12:55

Do you mean something like (list-insert '(1 2 3 4 5) 2 '(a b c)) -> '(1 2 a b c 3 4 5) ?


capfredf
2022-4-1 22:30:30

So does list-update :cry:


capfredf
2022-4-1 22:31:05

’(1 2 (a b c) 3 4 5)


sschwarzer
2022-4-1 22:43:54

Maybe not the fastest implementation, but not too bad IMHO: (define (list-insert old-list position new-list) (define-values (head tail) (split-at old-list position)) (append head (list new-list) tail)) Leave out the the list application in the last line to get the behavior I thought of first.


capfredf
2022-4-1 23:06:38

Thanks. I was just curious why there isn’t one. Implementing it is less of a problem. Also @notjack ’s rebellion has one.