freenode/#lisp - IRC Chatlog
Search
12:17:56
jmercouris
hi guys, I am having a bit of a mental block here, let's say I have list like this (list 0 1 2 (my-fun 10)), how can I get the evaluated list where (my-fun 10) --> 10
12:22:03
ck_
maybe you want (mapcar (lambda (elt) (if (and (listp elt) (functionp (first elt))) (apply 'funcall elt) elt)) list)
12:23:19
jmercouris
however I want to store the unevaluated, aka quoted from of the list, and then the evaluated form of the list
12:24:29
jmercouris
I want to store the unevaluated form as well because if I change some of the functions, I would like the new output
12:41:46
pjb
(defun my-fun (x) 10) (let ((have-list '(list 0 1 2 (my-fun 10)))) (eval (first (last have-list)))) #| --> 10 |#
12:43:31
pjb
jmercouris: on the other hand, if you want to save both the unevaluated form and the evaluated form, perhaps eval is what you want. Unless you need access to the lexical environment, in which case a macro might be preferable.
12:45:54
pjb
(defmacro save-form-and-value (form stream) (let ((value (gensym)) (vstream (gensym))) `(let ((,value ,form) (,vstream ,stream)) (print ',form ,stream) (print ,value ,stream)))) (save-form-and-value (+ 1 2) *standard-output*) #| (+ 1 2) 3 --> 3 |#
12:46:38
pjb
jmercouris: have a look at DRIBBLE (some implementations write both the form and the values).
13:12:35
beach
Also, you can't be sure that people here know Java, so you need to explain what it is you want to do.
13:19:01
beach
bzp: If you want to learn Common Lisp, people here are more than willing to help, but it doesn't look like you do, so I am guessing it is unlikely that you will find someone to do this for you here.
13:19:23
ck_
bzp: I tried! Unfortunately, I failed at the first line :-( I don't know how to import java.util.* in Common Lisp
13:21:28
_death
here you go: (let ((a (make-array (list (read) (read))))) (map-into (make-array (reduce #'* (array-dimensions a)) :displaced-to a) #'read) (print a)) ;; HTH
13:28:53
ck_
bzp: okay -- you said you tried your hand at implementing it in common lisp. Can you show that code, please?
13:59:10
minion
bzp: please look at PCL: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
19:35:49
shka_
is it possible in asdf to ask to compile every file in the project as one compilation unit?
19:40:02
p_l
don't recall such function, but it could be possible to write something that makes it happen? a new kind of file which is interpreted to be concatenated from several others...
19:40:27
p_l
there's a problem that the only way to force single compilation unit iirc is to make it a single CL:COMPILE input
19:46:42
shka_
p_l: i don't think that this is true, standard explicitly states that compile-file works by wrapping input in with-compilation-unit (:override nil)
19:47:07
shka_
therefore, it should be possible to compile-file in loop while in with-compilation-unit
19:48:17
p_l
shka_: still, you will probably need to either modify existing ASDF compile-op, or implement your own as different file-type and inside of it call compile including with-compilation-unit
19:56:26
p_l
very interesting. I thought of various extensions one can use to implement their own compile-op, but I see there's some arguments already...
20:17:19
p_l
I was thinking if it would be possible to make an :around method around compile-op or something to verify what's getting passed, but now I realize it won't guarantee anything since I don't see a way to check for compilation unit
21:55:30
garbochock
new lisper (and programmer altogether) here. Currently reading 'a gentle introduction to symbolic computation' - which is a great resource for learning the basics of lisp. Looking at 'the little schemer' for further reading. My question is - where do one continue studying in order to learn how to write useful programs in lisp?
21:58:08
dialectic
I wouldn't read the little schemer. It's basically a book for teaching you how to think recursively.
22:00:16
dialectic
It does not teach you any of the interesting parts of Lisp, either: symbols, heterogeneous lists and property lists, macros, the object system, any of the sophisticated control structures in Lisp or the conveniences (like keyword arguments, rest arguments, #'APPLY . . .)
22:00:27
garbochock
really? My impression was that it was fairly generic - and as such could be easily applied to common lisp
22:01:21
dialectic
Then you'll probably benefit from that book. I don't often reach for recursion but of course it is indispensible when I ned it.
22:04:01
dialectic
I'm writing a compiler. I needed the dynamic type system and garbage collection so I wouldn't give myself a headache. I needed the macros so I could properly abstract over repeated patterns.
22:07:13
dialectic
garbochock: Let me show you a little macro I wrote the other day for lexing operator string sequences in source code. It isn't particularly good style and I take some liberties because it's only used in one place (I assume a free variable, I'm rather ad-hoc about the data structure, etc...) but it should be instructive anyway. And it's recursive.
22:08:39
garbochock
Please do. It might fly over my head honestly but im curiousn about individual user cases of lisp so it's greatly appreciated
22:12:39
garbochock
fyi I'm a 27yo 2nd semester compsci student with little background in the field prior - i'm very much fumbling in the dark
22:15:00
dialectic
ctrl-f "lex-operators". What I'm saying in that call is "every (string sym) pair should parse string and return sym". So if "..." appears in a source code file, that returns the token ELLIPSIS
22:16:17
dialectic
What that macro does, pay attention, is it takes that list of pairs (anyone else in here, please don't correct me that those aren't really "pairs"), and it sorts them lexicographically. Then it builds a finite state machine out of those strings.
22:17:15
dialectic
It takes the state machine - this is all happening at compile time! - and it recurses over it, building up the case-switch code that I've pasted at the end, peeking at the next char and advancing when necessary.
22:18:09
dialectic
You could use a regular expression... but this should show you how libraries like cl-ppcre do this very task
22:20:29
dialectic
You can't do this with a scheme "syntax-rules" btw. But you can do it with the various nonportable macro facilities in each scheme implementation.
22:25:02
dialectic
if you can't read that code, don't worry, after seeing that again for the first time in two weeks I can't read it either. Only slightly kidding.
22:26:22
garbochock
haha. No it's just over my level of understanding of the language. Seriously appreciated though - I need study material, and I need to look at code written by people knowing the language better than me
22:30:19
dialectic
Reading and writing are both important. On Lisp is a very inspiring book. Same with Let Over Lambda
22:30:38
dialectic
Basically if you keep using Lisp, you should read Practical Common Lisp -> Let Over Lambda or On Lisp or both.
22:33:35
garbochock
anyway thanks. turn in time for me - maybe see you around in the channel another point. night!
22:47:53
makomo
how come clsql's insert-records doesn't support inserting multiple records at once :(
22:55:19
dialectic
Ok, I haven't tested this yet, but I need some opinions: is string interning worth it for a well organized symbol table? I thought I'd get cheap string tests out of it but I'm wondering if the overhead for interning strings makes it come out the same.
22:58:58
aeth
Hmm, Ryzen 3000 is coming out tomorrow. It sure would be nice if a 12 core computer (the most in tomorrow's launch, but not overall) would actually be a substantial improvement in CL compilation times over a 4 core computer.
23:00:32
dialectic
Plus the whole bestiary of new features every few years. I would hate to be a maintainer for GCC or Clang.
23:01:05
aeth
Still, we should start a gofundme to send out as many Ryzen 9 3950X (coming out in September) to as many people involved in CL build processes and CL compilers. Only $749. https://en.wikipedia.org/wiki/Ryzen#Zen_2_microarchitecture
23:04:19
aeth
Not every compiler is thread safe afaik, which is why the last attempt to parallelize ASDF does heavyweight forking insetad of lightweight threads. Although they might have improved since then.
23:04:24
Petit_Dejeuner
Wasn't someone on here talking earlier about how SBCL uses fork or something?
23:05:22
Petit_Dejeuner
Side not, I feel like I'm losing my mind. I used to be apple to SBCL and SLIME working perfectly on any machine with little to no effort, but not it feels like the REPL is always broken for some reason.
23:06:42
dialectic
As one of the poor people using the SLIME package for Atom, I have never had a bug free environment