IRC channel logs

2022-03-12.log

back to list of logs

***mfiano_ is now known as mfiano
***alMalsamo is now known as lumberjack123
<mwette>o/
<robin> https://github.com/riscv/riscv-j-extension might be worth tracking, looks like it's a WG rather than an official extension atm (wingo: <-)
***karlosz__ is now known as karlosz
<dadinn>hi all
<dadinn>what's the best way to do boolean exclusive or in Guile?
<dadinn>I have 5 values and it should be only true if only one of them is true
<rlb>dadinn: depending on exactly what you want, perhaps convert the booleans to 0/1 and then (logxor v1 v2 v3 v4 v5).
<rlb>and then convert back to boolean
<dadinn>rlb: you mean there is no srfi or something else that already does this?
<rlb>There might be, but not one that I know of for boolean variables.
<rlb>s/variables/values/
<rlb>I believe logxor is in some srfi(s), though.
<rlb>(maybe under a different name - can't recall)
<pinoaffe>rlb: logxor does not do that
<pinoaffe>rlb: (logxor 1 1 1) is 1
<wingo>(or-map identity values)
<rlb>pinoaffe: ahh, right, thanks.
<rlb>wasn't thinking.
<pinoaffe>dadinn: if I understand you correctly, you want something along the lines of (define (boolean-exclusive . args) (= 1 (length (filter values args))))
<pinoaffe>wingo: isn't that just a regular or?
<dadinn>pinoaffe: regular or is not exclusive
<dadinn>wingo: or sorry, regular or is not exclusive
<dadinn>or sorry, just got mixed up in who wrote what :P
<ArneBab>dadinn: not super beautiful, but should be correct: (equal? 1 (apply + (map (λ(x) (if x 1 0)) (list #f #f 9 #f #f))))