freenode/lisp - IRC Chatlog
Search
11:44:06
phoe
Is anyone aware of some kind of server in Common Lisp that can accept an arbitrary number of TCP connections and pushes the messages it receives into some sort of queue?
11:44:37
phoe
I'm fed up with trying to write a robust one myself and I'd rather use a solution that doesn't break in subtle ways.
11:50:00
shka__
there are some tricky things in the API like dropping messages, high water marks but there is a plenty of people using this already so getting help should be simpler
11:50:34
pjb
phoe: Not at the level of TCP connection, but of IRC message, there's the botil example: https://github.com/informatimago/lisp/tree/master/small-cl-pgms/botil
11:50:51
pjb
phoe: https://github.com/informatimago/lisp/blob/master/small-cl-pgms/botil/design/f-botil.png
14:17:38
schweers
shangul: maybe you can create a large integer out of your fraction and emit it. placing the string "3." in front of it
14:20:15
jackdaniel
common lisp has bignums, *yes you can* ,) admittedly that depends how much memory you have on your system
14:20:53
White_Flame
if you multiply by 1000, for instance, then FLOOR it to an integer, the rendering of it might be "1234567" which would correspond to "1234.567"
14:21:54
White_Flame
that would be your input requirement, in this case "I want 3 decimal digits of fractional precision"
14:22:26
jackdaniel
shangul: I think you need to be more precise with "what you want" before anyone can give you better hints on how to do that
14:22:30
White_Flame
and you could go as high as you want, well beyond what built-in floating point gives you
14:23:35
White_Flame
the reason I asked about precision is that if your requirements fit in single or double floats, just use those
14:24:11
shangul
I'm trying to calculate Pi. I've written a function returning a fraction/ratio which is Pi but I'm not sure how can extract digits of Pi
14:26:48
shangul
White_Flame, the problem is that I don't know how many digits I want. In that case 1000 was just an example
14:27:06
White_Flame
however many iterations your calculation performs determines how precise it gets
14:28:24
schweers
This seems to be a case of not understanding the problem space well enough. This does not necessarily have to do anything with lisp.
14:28:59
White_Flame
well, with arbitrary precision floating point libs, there could be specifics about them
14:29:46
White_Flame
also, there are algorithms to calculate arbitrary decimal digits of pi, random-access style, iirc
19:22:31
Xach
skidd0: slot-boundp is a function, and follows normal evaluation rules. so to pass a name (represented by a symbol) you must make sure the argument evaluates to the right symbol. it's common to use ' for that.
19:23:02
Xach
(slot-boundp p 'google-product-type) might work if the current package is appropriate.
19:23:34
Xach
skidd0: no. p evalutes to the object instance. the second argument must evaluate to the name.
19:23:42
mfiano
No, it should be exactly what Xach wrote, assuming your slot name (not accessor) is GOOGLE-PRODUCT-TYPE
19:24:04
Xach
or to a symbol, rather - whether it's the right one depends on how the class is defined.
19:27:16
pjb
skidd0: (defclass point () ((x :initform 3) (y))) (let ((object (make-instance 'point))) (slot-boundp object (progn (write-string "what slot?" *query-io*) (finish-output *query-io*) (read *query-io*)))
19:28:16
skidd0
okay, got it working now, thanks. so the quote operator ensures i'm passing in the symbol google-product-name rather than evaluating google-product-name and passing the evaluation in?
19:28:33
mfiano
In Common Lisp, arguments to functions are evaluated before the function is applied to those values, so it's common to use QUOTE to prevent evaluation in this case, since you only want the name of the slot, not what symbol-value may be currently bound to the symbol.
19:30:08
pjb
(slot-boundp (make-instance 'point) (intern "X")) #| --> t |# (slot-boundp (make-instance 'point) (intern "Y")) #| --> nil |#
19:56:17
refpga
Hello, how can I convert a list of lists and atoms to a single list of atoms? like (5 (2 3) (45 7)) to (5 2 3 45 7). Earlier I was using (reduce #'append list) but that only works if all the elements of the list are lists.
19:57:40
mfiano
Keep in mind, a vectors are atoms too. If you would like it to flatten array elements as well, it requires a slight modification.