freenode/#lisp - IRC Chatlog
Search
20:24:00
H4ns
flip214: intern is the wrong tool. you can't ever have a slot named by a symbol that did not previously exist. if you absolutely need to lookup a slot name at run time, find-symbol is what you'd use.
20:26:57
flip214
hmmm, my cltl2 reads to me differently - with terms "package" vs. "package name". but never mind, have a nice weekend!
20:33:57
em1l
H4ns: thank you so much, it's working! also big thanks to pjb, both of you for giving me some thoughts to learn :) have a nice friday!
20:53:06
dim
stumbled on (thx twitter) https://github.com/mshang/python-elevator-challenge ; do we have anything like python doctest?
21:39:41
Mitzelflick
Is there a lisp tool for doing scripty things like bash does but with lisp panache?
21:44:59
dwchandler
Mitzelflick: like myscript.lisp with "#!/usr/bin/sbcl --script" as the first line?
21:46:16
Yanez
Mitzelflick: I sometimes write simple scripts in clisp, it's very easy and clisp startup is pretty fast
21:47:52
Mitzelflick
I wrote a bash program to move the file and capture from time (somebash) the readout, using 2>>myfile
21:50:29
jasom
Mitzelflick: or if you want it to return the time you could write a macro to do something like (let ((start-time (get-internal-real-time))) stuff (/ (- (get-internal-real-time) start-time) internal-time-units-per-second)))
21:54:43
dwchandler
Mitzelflick: bash is easy because whatever you type into the command line can become a script. the more complex you get, the less "easy" bash gets. But lisp is fully featured :)
21:55:38
Mitzelflick
can a web site then be simply some abstractions to make forms, a lib or 2 to spit out nice pages, and a bunch of evergrowing lists with the data?
22:00:24
jasom
(float (with-time (uiop:run-program "dd if=/dev/urandom of=/dev/null bs=1024 count=1024"))) ;; => 0.061
22:02:02
jasom
measuring CPU time of spawned programs is somewhat more complicated, but for copying files you are often not cpu bound, so this should be fine for your example use case of timing a file copy
22:08:15
jasom
here's an even simpler example that yields the time it takes to run a system shell that just sleeps for 3 seconds: (round (with-time (uiop:run-program "sleep 3")) 1/1000)
22:15:10
mordocai
ralt: implementation specific what you get and more data than just the real time it took which was the thing the OP wanted.
22:29:31
ralt
call-with-timing takes 2 args: the first is a function that will have (among others) the user-time-ms argument, and the 2nd is the function to time
22:29:35
jasom
ralt: yeah, I was in cl-user on sbcl which is why I named my function call-with-time instead of call-with-timing
23:09:19
Bike
"simple" in a condition name means it's signaled by something that takes format arguments
23:09:29
drmeister
From what I read if I call (SIGNAL "a string") it will signal a simple condition.
23:13:07
drmeister
Would I use (error simple-type-error :format-control "something" :format-arguments nil :expected-type foo :datum bar)
23:13:27
drmeister
That's actually where I'm going with this - how do I set up the call to ERROR for a simple-type-error.
23:17:25
drmeister
I guess anything that inherits from simple-condition can initialize the :format-control and :format-arguments fields.
23:18:58
Bike
and, looking back, check-type more or less signals aa simple type error with a fromat like ("~s is not of type ~s" datum (or string (make-string-from-type expected-type)))
23:25:26
PuercoPop
jackdaniel: I left you an answer in SO. In addition to the libraries I linked to, I have incipient code for extending CLOS for Crud web apps if you are interested
1:30:13
BIGBOOMBA
Trying to put a basic UI on a gin-rummy engine I wrote. Just a loop that looks at the game state and gets the next decision from the user, e.g., (princ "Enter card to discard: ") ... (read-line)
1:30:55
BIGBOOMBA
The only issue is the chatter that is produced in the REPL: user enters, say, "3h", and (read-line) prints that out as its return value. How do I suppress that so that it's cleaner?
1:31:47
BIGBOOMBA
I have the Land of Lisp text-engine chapter open in another tab, and I'm trying to go back through it and see how he set it up.
1:33:09
BIGBOOMBA
Hmm, maybe I need to assign the value of (read-line) to a local variable and then return that to the caller of the user-prompting function, so that the value of the user-prompting function isn't the string entered by the user.
1:34:46
BIGBOOMBA
Okay, that gets SLIME to just print the string entered by the user instead of that string, a newline, and then NIL, but still not there.
1:55:46
BIGBOOMBA
Nevermind, I'm pretty sure the REPL will only spit out some value at the very end of the game
4:57:41
aptenodyte
does anyone know what the status of mocl is? It seems like such a cool compiler, and I always thought about trying it out, but they haven't updated in a bit. It'd be a shame if the project died.
5:00:09
aptenodyte
oh, I just mean being able to write CL apps directly for Android / iOS, that played nicely with their SDKs
6:05:39
drmeister
beach: I wanted to ask if I can still pull sicl. It's been months since I pulled it. Have there been any changes that will break much?
6:27:44
JokesOnYou77
I'm trying to get a function with this contract: (func '(a b c) d) ==> (c(b(a(d))) I really thought I had something with (reduce (lambda (x y) (funcall y x) func-list :initial-value init) but it's complaining that the final value isn't a list, which seems odd.
6:28:51
JokesOnYou77
P.S. I think I may have asked a similar question a few months ago, been very happy with the perfectly good response, used it, and then immediately forgotten it.
6:33:31
beach
JokesOnYou77: Do you mean that A, B, and C are names of functions in the global environment?
6:37:13
JokesOnYou77
Could be anything. But for an example: (my_func (list #'(lambda (a) (apply #'+ a)) #'write-to-string) '(1 2)) ==> "3"
6:37:29
JokesOnYou77
Wait, I got it! (reduce #'(lambda (x y) (funcall y x)) (list #'(lambda (a) (apply #'+ a)) #'write-to-string) :initial-value '(1 2))
6:41:07
JokesOnYou77
(defun transformer (transformers doc) (reduce (lambda (x y) (funcall y x)) transformers :initial-value doc))
6:42:24
beach
I don't know what you are trying to do, and your explanation of the contract is weird, incomplete, and wrong.
6:42:33
beach
For example, you said that a, b, and c are defined as functions in the global environment, then you create a list of first-class functions with no definition in the global environment.
6:48:37
JokesOnYou77
This is a misunderstanding on my part. And thank you for pointing it out. Let's assume the test I put forward corresponds to the desired behavior. Can you help me define the contract?
7:08:19
beach
JokesOnYou77: "I need a function that takes two arguments. The first argument is a list of functions, and the second argument is any value. The function should return the result of applying the composition of all the function in the list to the second argument, with the first function in the list being applied first.
7:10:34
beach
JokesOnYou77: You might even specify that each of the functions in the list can be applied to a single argument.
7:12:26
JokesOnYou77
beach, Thank you very much. That was clarifying. I shouldn't have muddied the waters with quotes, especially when I clearly don't understand the full meaning.
7:35:07
moore33
beach: I've had a productive couple of weeks working on LPSG. I next need to add the possibility of deleting graphic objects; after that it might be usable for real code.
8:04:41
beach
moore33: I am a bit uncomfortable about all this GUI backend stuff, mainly because of my ignorance. On the one hand, X11/CLX is what I have on my machine. On the other hand, everybody says it is outdated and must be replaced.
8:04:42
beach
But then I hear that OpenGL still uses X11 for communication, and that we still need X11 for input. Perhaps we need a more abstract backend layer that can then translate events and requests to every possible combination of concrete backends?
8:06:43
beach
Oh, and not to mention the FFI problem. I was very comfortable with CLX because it uses a minimal amount of code in some language other than Common Lisp. But then you told me that progress requires using MORE FFI rather than less.
8:08:58
moore33
OpenGL, at least when used locally, uses a little part of X (these days potentially even less) to initialize and destroy graphics, swap buffers, etc.
8:17:24
beach
I mean, I can understand why it is currently the option with the lowest effort, but I can't understand why it must be so.
8:18:47
moore33
beach: Just to make the calls. I suppose another option is to write your own driver that exposes undocumented GPU internals to Lisp, but my life is to short for that:)