freenode/#lisp - IRC Chatlog
Search
10:00:34
specbot
Modifying Hash Table Keys: http://www.lispworks.com/reference/HyperSpec/Body/18_ab.htm
15:23:27
flip214
Is there some function that can convert a number to some indirectly specified type?
15:23:59
flip214
I'd like an average to be of the same type as the input (integers, floats, ratios), but (coerce (/ sum count) (type-of (first input))) doesn't work
15:30:03
shka__
there is no generic function for this because it wouldn't be usefull for general use
15:35:06
Bike
i'm with loke in not understanding why you want this. you'll have to apply these rules yourself by checking the classes of the arguments.
15:35:49
Bike
unlike the contagion rules in the language arithmetic these don't even associate, i don't think
15:36:12
pjb
If you want to convert numbers to numbers, some rounding will be necessary. And even, how do you round #C(2 2) to integer? Is it 2? 3? 4? does this mean anything?
15:37:29
loke`
And even if you have solution in your specific case (such as for example just taking the realpart of a complex number), that's never a generic solution.
15:37:49
flip214
pjb: I'd like to print average and stddev in the same format as the input.. so that column values (1 2 3 4) don't require a 2.5 in the "average" row
17:48:32
galdor
is there any issue with APPLY-ing a function with &REST arguments such as MIN on very large lists ?
18:39:23
galdor
so if I want to find the minimum of a list with maybe a key function and a predicate, I should write it myself
18:47:29
bbsl
does cl base have any way to manipulate strings like lists? I just need a way to from a string get head (the first char) and tail (the rest of the chars)
18:49:39
Xach
bbsl: you would use subseq to get parts of the string. or you could displace an array to parts of the string. the sequence operations have different implications than with lists.
18:54:58
Xach
bbsl: any new cool info about what you're doing so we can offer more suggestions? some of them possibly helpful?
19:04:43
bbsl
Xach: well I didnt get much wiser. Online I found a string-to-list function referenced but its not part of the std lib so meh. I can use (subseq) I guess but that wont work for be because I do not know the start and end of these "sequences" other than by index. I guess the mythical sequence start/end params mentioned here is the answer to my question
19:08:35
Xach
I guess my general advice would be "don't try to work with strings like that if you can avoid it"
19:10:34
bbsl
Xach: Im sure but this is my 3rd day (I guess hour even) of cl so I am not expecting my code to be very idiomatic
19:11:19
Bike
you can also just write out '(#\h #\e #\l ...) if you really want a list. or (coerce "hello world" 'list)
19:11:20
jasom
bbsl: I usually use a string and an offset for that case. Then head would just be (char string offset) and tail would be (1+ offset).
19:18:46
aeth
bbsl: In general, most things are sequence-generic, which includes strings, which are just character vectors
19:19:17
aeth
bbsl: If you're clever and you need an output list, you can e.g. use MAP to take advantage of this
19:20:14
aeth
(map 'list #'char-code "hello world") ; combines the conversion-to-list step with a processing step, in this case #'char-code
19:21:17
bbsl
aeth: ahh right Il remember that. At least map is somewhat familiar in this language even though it has like 6 of them :)
19:22:11
aeth
This is the equivalent in LOOP. Notice there is a slight difference because you use vector's :across instead of list's :in. (loop :for char :across "hello world" :collect (char-code char))
19:23:09
aeth
It's just that :collect automatically builds a list instead of having to manually do so in :do
19:23:55
aeth
bbsl: As for the various variations of MAP, only MAP itself is generic, the others are specific to lists. MAPCAR is very roughly equivalent to MAP, but for lists alone.
19:49:56
bbsl
aeth: ok thank you for the clarifications though I am not familiar with the :<bar> syntax of ie loop yet. I know you use :<bar> :<baz> to adress variables (?) in objects (?) but for lopp ie I am writing it like (loop for i from foo to bar <blergh>) ie. though I know you can do (loop :for ). I guess it makes sense if what I said first and loop is a iterable object or smt?
19:52:20
Bike
there are reasons to use one or the other, but they're boring and you shouldn't worry about it
19:53:24
bbsl
yea I am just not very confident with the syntax but I know that both work, though I am not sure why yet :)
19:54:42
jasom
bbsl: once you are more comfortable with lisp they are quite easy to reason about, but until then it will likely just confuse you more
19:55:23
bbsl
hmm I guess I will put it off then. for now my goal is just to fiddle around with the language
19:56:21
bbsl
Also. Does anyone know if there is a way (prefrably in slime) to given a type list out the functions available (prefrably in my env) that works on that type
19:56:51
Bike
not really. that concept makes less sense outside of an environment like java where functions are tied to classes.
20:00:40
bbsl
well it would increase discoverability by a lot. In haskell ie you can use hoogle to search for a function signature that matches what you want. In cl I feel stuck some times because I do not know the names of functions
20:04:38
Bike
plus there are higher order functions but not universally quantified types, so some things would be hard to express
20:17:09
boeg
I've only been using sly in emacs to run common lisp, but now I want to run a script in a shell. Problem is, I have been using quickload to load modules, but this doesn't seem to work when I do "sbcl --script script.lisp", says it can't find QL which I use to require the module "split-sequence". How do I use a module with sbcl like that?