freenode/lisp - IRC Chatlog
Search
9:37:35
gabbiel
for example, I want a glue generic function that will take &rest atoms and "glue" them
9:39:36
no-defun-allowed
can't specialise on &rest arguments, but maybe something like (defun glue (&rest parts) (reduce #'glue-two-parts parts)) could work
9:40:06
no-defun-allowed
or, use the printer: (defun glue (&rest parts) (format nil "~{~a~}" parts))
9:40:20
gabbiel
it just seems better to be able to glue as many things as I want like with (glue 1 2 3)
9:51:58
gabbiel
strings are a problem though, maybe I should drop strings since i dont have a use for them yet
9:51:58
pjb
gabbiel: you can use &rest in generic functions, but methods are not dispatched on other than mandatory arguments.
9:58:09
ggole
You could write glue2 with a generic function and then fold it over the argument list of a non-dispatching function
10:00:37
pjb
gabbiel: infering the type of the result is probably wrong. instead, pass the type of the result as first argument, like with concatenate or map.
10:33:02
pjb
gabbiel: notice that (glue 1 -2 3 -4) #| ERROR: The value #C(0.60206 1.3643763) is not of the expected type real. |#
10:34:31
pjb
gabbiel: (defun glue (&rest args) (with-output-to-string (*standard-output*) (mapc (function princ) args))) (glue 1 'two "three" 1 0 0 2 1 -2 3 -4) #| --> "1twothree10021-23-4" |#
10:36:05
pjb
gabbiel: what I'm saying is that your problem is not function or method, &rest or not. Your problem is to specify what you want.
10:36:43
gabbiel
it dawned on me that glue should literally glue it, so it follows that gluing integers and strings makes sense
10:45:27
gabbiel
I only came about this "glue" business to glue integers for a backtracking algorithm
10:46:17
gabbiel
i tried to extend gluing to symbols and strings, which arose ambiguity and design problems
11:04:19
pjb
gabbiel: glueing still doesn't mean anything. Why should (glue 12 34) return 1234 instead of say 802 ?
11:04:45
pjb
gabbiel: ie. why do you use the base ten textual representations and concatenate them, instead of the base two or something else?
11:05:27
pjb
gabbiel: obviously, you can define any arithmetic operation, but what meaning does that have?
11:17:53
jonatack
mrcode_: git grep 25519 from within the ironclad repository turns up tons of results... git grep is your friend ;)
12:18:05
gabbiel
pjb: well, for my use case, I needed to "glue" integers and then "explode" the result to get the individual digits so that I could sum them up and divide by the length of the explosion
12:20:03
gabbiel
pjb: i understand your points, I guess this is more an operation on the literal symbols that represent a number
13:03:05
pjb
gabbiel: you should probably just convert your stuff to strings, and process only strings.
15:45:43
Josh_2
Should I use json for config files? is there a better alternative? just need to store some user configured values and then import them into my program when it starts up
15:52:59
LdBeth
so the config can be set to the lisp file to load during startup when you save the lisp image