freenode/#lisp - IRC Chatlog
Search
22:28:28
pjb
phoe: no, that's the point, there is no "the" index of item! There are several indices of item!
22:28:57
pjb
(loop with list = '(1 2 1 2 3 4 1 2 3 4) for item in list collect (positions item list)) #| --> ((0 2 6) (1 3 7) (0 2 6) (1 3 7) (4 8) (5 9) (0 2 6) (1 3 7) (4 8) (5 9)) |#
2:44:57
vtomole
Good :). I really enjoyed the paper, will have to study the code a bit longer though specifically %apply-nQ-gate
2:46:19
vtomole
From the paper "Since qubits live in a two-dimensional space " should it be "Since a qubit lives in a two-dimensional space"?
2:52:14
vtomole
What is the performance comparison of implementing linear alg operations instead of handing them over to BLAS?
3:47:03
vtomole
stylewarning: Looking for feedback on the new pull request: https://github.com/tarballs-are-good/quantum-interpreter/pull/1/commits
9:50:44
makomo
say i have a CASE form and i want to run a bit of code before/after the CASE form, depending on whether any of the cases within the CASE was actually hit
9:51:31
makomo
i could do it by adding WHENs before/after the case and then checking for all of the symbols within the case, but this duplicates all of those symbols
9:53:33
ludston
Alternatively, you could yield a non-null value from all of your cases and wrap it in an if or when expression
9:54:38
makomo
plus, it requires me to save that value then somewhere, which means the whole CASE needs to be wrapped within a LET, producing "ugly" indentation
9:54:52
makomo
if i opt for (setf) instead of returning, then i'm again duplicating code within the clauses
9:56:12
ludston
In that case, whether or not this is a better way to do this, I would have the case return a lambda and then wrap the clauses around that
9:56:26
makomo
another style/philosophy issue: where do you draw the line between "i'll just write a macro for it and introduce my own control structure" and "i should probably just let this bit of duplication be, it's not worth the reader's effort to decipher what i meant"
9:58:20
makomo
you want to run some common code, then special code for every clause, then again common code
9:59:17
makomo
i also thought about that, and that's an upcoming optimization, but isn't *that* important
9:59:48
ludston
(let ((c (case "jobbo" ("jobbo" (lambda () (something)))))) (when c (setup) (funcall c) (cleanup)))
10:00:21
makomo
so for example, you can't rely on the check being saved in the after body, if the before body never existed
10:01:23
makomo
in the after body, you can't rely on the check being saved/done already, if the tbefore body never existed**
10:04:19
ludston
makomo: I've found that if you have conditional behaviour, it's often better to delay executing that behaviour by passing it around in higher order functions, since then it is trivial to add logging later
10:05:40
ludston
makomo: Often, conditional behaviour is going to be triggered by some user-input, and the user will input data outside of the range that you predicted, so you will want to anticipate this
10:06:40
ludston
makomo: And by that I mean, anticipate that you will screw up your code, not "try and make sure that all of the inputs are santized"
10:10:23
makomo
i think i see what you mean. so you're referring to the process of actually writing the code, not the runtime behavior of the program
10:12:11
puchacz
by the way, is there "case" with different test instead of default "eql"? or I would have to write a macro (or use one of the libraries)?
10:13:55
loke
puchacz: To your question. You asked if there is such a macro, or if you have to write it yourself. The answer to that question is “yes”.
10:15:20
loke
siraben`: Also, I believe it mentions lispbox or some other similar package which are no longer devloped. You should be looking at Portacle.
10:15:23
makomo
siraben`: skip the part about "lispbox" in the beginning and use something like Portacle instead
10:15:38
siraben`
Fortunately I know how to use Emacs, so I'll find a way to customize my current configuration to work better with CL
10:16:13
loke
makomo: There is a STRING-CASE in Quicklisp which is likely much faster than what you'll be able to write.
10:16:40
makomo
loke: probably, i had no idea though. i expanded it into a COND which uses STRING-EQUAL lol
10:17:07
makomo
loke: what kind of optimization could it do. hash the strings and compare the hashes perhaps?
10:17:16
loke
makomo: smartparens was less efficient last i looked. That said, it also seemed to be easier to learn, so perhaps it's a good idea for beginners.
10:18:30
makomo
ludston: i just learned something :D. i use spacemacs's lisp-state for my sexp operations though
10:18:50
makomo
the keybinds aren't the shortest, `SPC k <something>` and then just `k <something>` once you're in the state
10:18:58
loke
makomo: it finds common prefixes and constructs a tree based on that. Then it compares multiple characters by OR-ing the differences and comparing to zero. It has hand-optimised assembly for SBCL so that it only does a comditional jump every four characters (if I remember correctly)
10:22:16
loke
teh code contains this comment, showing the output: https://gist.github.com/lokedhs/beddab3cdfbc72ebcad9df72939efd80