freenode/#lisp - IRC Chatlog
Search
9:20:31
White_Flame
that list of 3 elements can be evaluated into 2, or be transformed around before evaluating, or injected somewhere else as custom code into other code bodies, etc.
9:21:22
White_Flame
macros can access the source code so it's nice to be able to log out the actual source code. Can't do that easily in most languages
12:30:34
mykon
mm.. Is lisp console capable of sed operations? Even better does lisp have 1:1 list of sed features built in?
12:32:20
Xach
mykon: I don't mind the sbcl repl that much, but most people don't use it directly, they do so via slime in emacs.
12:34:25
Xach
mykon: if the array is adjustable, you can adjust it and setf the new index at the end.
12:35:47
Cymew
mykon: http://clqr.boundp.org/ is a very good reference if you want to know what's built in, array wise, list wise and so on.
12:41:40
mykon
so let's say, I want to process a string and return an array. Is this doable in lisp?
12:42:14
mykon
this is the equivalent awk --> awk -v N=4 '{a[((NR-1)%N)+1]=$0} NR%N == 0 { for(i=1; i<=N; i++) { printf "%s%s", s, "X"a[i]; s=OFS }; print ""; s=""}' file.txt
12:48:06
White_Flame
mykon: awk is a pretty specific programming language for dealing with text formatting. Like in any other general purpose language, if you want utilities focused on that, you'll have to look at libraries
12:49:46
Cymew
mykon: https://shinmera.github.io/portacle/ might be helpful to get an environment up and play along with the book link mentioned above.
12:50:26
White_Flame
(vector-push x some-vector), or (push x some-list), or many other things depending on what your chosen datastructures are and what features you want
12:52:03
igam
(let ((a '(1 2 3)) (b '(4 5 6)) (c '(7 8 9)) (x '(a b c))) (mapcar (lambda (head) (append head x)) (list a b c))) #| --> ((1 2 3 . #1=(a b c)) (4 5 6 . #1#) (7 8 9 . #1#)) |#
12:57:41
mykon
where can I find a repository with small utilities in lisp? I'd like to peek at the sauce.
12:58:34
antoszka
mykon: for every package you download via quicklisp, you're able to browse the sauce
13:06:19
igam
Cymew: of course, but then in emacs you already have written a nice little command that identifies any sexp in erc, copies it in *scratch* and insert newlines and pretty-print it, haven't you?
13:06:59
knobo
When I start slime after opening a file with tramp or sudo, slime is started on remote computer or as root
13:07:21
igam
mykon: or you can redirect nasty comments to #lispcafe, there we can take stronger beverages and speach ;-)
13:12:37
Xach
igam: If that's the kind of discussion you want in #lispcafe, do not advertise it here.
13:17:16
Xach
igam: I disagree. If you encourage people who talk that way to join #lispcafe, do not advertise #lispcafe on #lisp.
13:19:30
igam
Xach: how will they know where to talk like you don't like if you don't tell them where to go?
13:20:28
Xach
igam: That is not my concern. That kind of talk is not welcome here, and advertising a forum where it is welcome is not welcome here either.
13:33:08
jfe
"any discussion that is sufficiently meta is indistinguishable from off-topic banter." - jamie zawinski
13:33:49
JuanDaugherty
wouldn't it be great if minion could monitor and admonish the way bots on wiki autorevert?
13:34:56
Cymew
I could see that being ripe with false positives, and probably very tempting to "game" as well.
13:44:01
splittist
jackdaniel: Thanks. I wonder what the prevalence of the various CL printing forms is in, say, the default quicklisp distro...
13:44:45
igam
(format t "~A: We could probably also ~A it with ~:[false~;true~] ~:*~:[negative~;positive~]~p." "Cymew" "trick" nil 2)
13:49:30
jusss
http://paste.ubuntu.com/23522176/ I wrote a simple nth-eval macro, and it doesn't work
13:51:24
dlowe
macros are compiler-helpers that take in code as an argument and emit code as a return value.
13:53:52
jusss
dlowe: (nth-eval (+ 1 1) 1) should return (+ 1 1) to repl, and (nth-eval (+ 1 1) 2) should return 2 to repl
13:55:34
jackdaniel
splittist: I'm using mostly format, but after seeing its implementation I'm terrified each time I use it ;-)
13:56:19
jackdaniel
like, you know, calling some sacred words moving seven spiritual spheres to get your dishes cleaned up ^_^
13:56:22
dlowe
jusss: I think you probably want to split the eval part into an nth-eval-helper function
14:07:18
dlowe
dlowe: (nth-eval (+ 1 1) 1) should return (+ 1 1) to repl, and (nth-eval (+ 1 1) 2) should return 2 to repl
14:09:37
dlowe
the repl Reads an expression, Evaluates it, Prints the result of the evaluation, and Loops back to the beginning.
14:10:33
dlowe
So if you wanted the macro to return (+ 1 1) to be evaluated, then the repl would print 2 regardless of n
14:18:30
igam
jusss: at macroexpansion time you won't have access to the function and to the variables.
14:20:18
pipping
* is having issues pushing/pulling to/from gitlab.common-lisp.net over SSH (HTTPS works)
14:24:39
White_Flame
jusss: if you want to work with runtime values, then use functions, not macros. If you want to generate new source code, use macros
14:25:20
White_Flame
if you want to statically transform source code into a more optimized state, then look at compiler macros, not regular macros
14:25:26
dlowe
* is a believer in letting newbies do all the impractical things they want so they can explore.
14:29:29
jusss
if there's an expression, eval it and get another expression, then you can eval it and then eval it, again and again
14:31:05
dlowe
jusss: there are a few problems. One is that you can't really recurse with macros. You can emit code that calls the macro again.
14:31:14
igam
So (defmacro eval-n-times (n expression) `(loop repeat ,n do ,expression)) (eval-n-times 3 (princ 'hi)) #| hihihi --> nil |#
14:31:36
igam
Here the generated code looks like: (macroexpand-1 '(eval-n-times 3 (princ 'hi))) #| --> (loop repeat 3 do (princ 'hi)) ; t |#
14:31:42
White_Flame
so if you have (foo x 3), and that should generate (eval (eval (eval x))), then try constructing a form like that from code. Then put that code into the macro body
14:35:01
igam
(defmacro eval* (expression n) (let ((r (gensym))) `(loop for ,r := ,expression :repeat ,n :do (setf ,r (eval ,r)) :finally (return ,r)))) (macroexpand-1 '(eval* x 3)) #| --> (loop for #1=#:g6903 := x :repeat 3 :do (setf #1# (eval #1#)) :finally (return #1#)) ; t |#
14:37:31
igam
Now, you can optimize it when n is an integer: (defmacro eval* (expression n) (if (integerp n) (wrap-calls n 'eval expression) (let ((r (gensym))) `(loop for ,r := ,expression :repeat ,n :do (setf ,r (eval ,r)) :finally (return ,r))))) (defun wrap-calls (n fun val) (if (zerop n) val (wrap-calls (1- n) fun `(,fun ,val)))) (macroexpand-1 '(eval* x 3)) #| --> (eval (eval (eval x))) ; t |#
15:00:53
PuercoPop
oleo: he doesn't want the symbol :, but wonders how every implementation treats the package marker
15:04:20
PuercoPop
me wonders if this would be considered a bug in the reader of the other implementations
15:04:47
jackdaniel
(make-symbol "") returns #:||, so its not illegal to have symbol with empty string as name
15:07:24
PuercoPop
Xach: yes, their reader appears to treat : as a keyword with the empty string as its name consistently
15:12:54
oleo
Xach: i have linedit in my normal repl..... that's why, i tried it on a bare sbcl --no-sysinit --no-userinit it errors with "illegal terminating character after a colon"
15:13:33
splittist
Xach: I mean it doesn't rule in or out a bare : . Neither does the reader algorithm, on my (quick) reading.
15:15:20
Xach
It's part of an html generation syntax, so it may actually have significant value as a keyword.
15:15:47
Xach
It's also at least 16 years old, so it certainly doesn't pose a problem for the host Lisp.
15:21:43
PuercoPop
My understanding of the reader algorithm is that ":" should be read as a keyword with the empty string as its name
15:27:11
splittist
PuercoPop: the algo itself just says that a token will be returned unless it's not of valid syntax.
15:30:06
oleo
unexpected end of file on #<SB-IMPL::STRING-INPUT-STREAM {1002A98B13}> after reading a colon
15:34:19
oleo
when you backtrace it you see that it is read via (read-preserving-whitespace) (read-maybe-nothing) (read-token)....
15:38:22
splittist
As a programmer, rather than an implementor, using :|| (in analogy to ||) seems best practice if you really want to refer to the symbol in the KEYWORD package with the empty string as a name.
16:57:01
shrdlu68
i.e by placing the cursor on one of the parens, the region up to the matching paren is selected.
20:32:51
Xach
I don't use it because SBCL works for me for my tasks. SBCL is faster and more mature. But no other CL runs on the JVM like ABCL does.
20:34:26
akkad
abcl is quite nice. as long as you have the full maven install, things work quite well.
20:41:29
younder
akkad, we have had a long and heated discussion about this before. Suffice it to say that among the free alternatives I prefer SBCL.
20:42:26
flip214
I can't tell the reader that symbols interned into one specific package shouldn't be case-inverted, right?
20:43:05
Xach
flip214: no, that is controlled by a special variable that is not tied to a package object.
20:44:16
younder
I might have prefered LispWorks but I find it's pricing on a personal 64 bit version to high for my uses.
20:50:29
younder
Case sensitivity tends to mess with compatabillity when you try to share a module and is generally more troble than it is worth in my experience.
20:58:30
Xach
younder: you could make $foo read as a symbol named "foo" rather than one named "$FOO".
20:58:59
Xach
You install a reader macro on $ that reads the subsequent symbol syntax and interns it the way you want.
21:00:55
Xach
younder: No, I think that is a means to an end, and a read macro is a separate one that may work better for his use-case.
21:04:22
younder
flip214, Xach has a point you could do (let (*readtable* (copy-readtable nil)) and then locally do a (readtable-case ..)
21:05:48
younder
Remember special variables work for all function calls in that scome. It is not lexical.