IRC channel logs

2023-08-10.log

back to list of logs

<apteryx>'any' is a more general 'find', is it?
<RhodiumToad>any returns the result of the predicate, find returns the list element
<RhodiumToad>(any even? '(1 2 3)) => #t, (find even? '(1 2 3)) => 2
<apteryx>(any (lambda (x) (and (even? x) x)) '(1 2 3)) => 2, (find even? '(1 2 3))
<apteryx>=> 2
<apteryx>thanks
<RhodiumToad>finding a value of #f in a list that way can be hard :-)
<RavenJoad>Does guile have a procedure for getting a file's extension? I found basename to get the file's base name, but I am unsure how to get the extension beyond getting the final element of a string-split on the period.
<RhodiumToad>something with string-drop and string-index-right
<RhodiumToad>(and=> (and=> (string-index-right fn #\.) 1+) (cut string-drop fn <>))
<RhodiumToad>or
<RhodiumToad>(and-let* ((pos (string-index-right fn #\.)) (dlen (1+ pos)) (ext (string-drop fn dlen))) ext)
<RhodiumToad>or
<RhodiumToad>(and-let* ((pos (string-index-right fn #\.))) (string-drop fn (1+ pos)))
<apteryx>how do I delete a breakpoint at the REPL?
<apteryx>,delete wants an argument
<apteryx>,del 1 is not happy
<apteryx>(I have just one defined)
<apteryx>,traps says "No traps set."
<apteryx>OK, I think it was in some nested state and confused; exiting to the top level things look saner
<apteryx>the debugger is hard to use (it's hard to see where we are/the context), but tracing is helpful
<rlb>RhodiumToad: suppose you could also use basename and then drop that many chars from the original.
<rlb>(if the basename algorithm is suitable for you)
<RhodiumToad>basename only removes the extension if you specify it? and it removes dirs
<RhodiumToad>(basename "foo/bar.baz") => "bar.baz"
<apteryx>interesting, tracing gives me an error, while evaluating normallly is fine: In procedure primitive-call-ip: Wrong type argument in position 1 (expecting PRIMITIVE_P): #<procedure 7faca22aa760 (_ _ _ _)>
<apteryx>here's more context: https://paste.debian.net/1288526/
<apteryx>without ,trace: (rewrite-url "https://dist.libuv.org/dist/v1.45.0/libuv-v1.45.0.tar.gz" "1.45.0")
<apteryx>=> "https://dist.libuv.org/dist/v1.46.0//libuv-v1.46.0-dist.tar.gz.sign"
<apteryx>there's obviously a bug as well ^^'
<RavenJoad>RhodiumToad: Right, my bad. I w2ill take one of your three suggestions and throw it in a function that returns the file's extension.
<RhodiumToad>the third one is best
<RhodiumToad>(and-let* is from srfi-2)
<RavenJoad>Is (apply execl `(...)) or (execl ...) more idiomatic?
<RhodiumToad>where's the list coming from? if it's being formed purely to make the call, then use (execl ...)
<RhodiumToad>apply is generally for when you have an existing list and want to pass it as separate args
<RavenJoad>The arg list is being constructed by me.
<RavenJoad>Right now it is (execl "/path/to/highlight" "highlight" "--force" ... file-to-highlight).
<RhodiumToad>I'd stick with that