freenode/#lisp - IRC Chatlog
Search
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?
21:29:20
no-defun-allowed
congratulations, Xach is the winner of random IRC game where one must write "/win 3" to win
21:44:07
bbsl
could someone please have a look at the bottom of https://rextester.com/BWJYD91713 . I am trying to (like I write in the comments) run a function against every item in a list but for each time it runs I want to take one of the (values x y) it returns and also feed that into the next call. My head is jumbled with all the new syntax and I am trying to use a let binding inside a collect but I guess thats not how you do it. I guess I can
21:48:41
_death
maybe something like (loop for dir in path for (m p) = (multiple-value-list (map-dir dir pos)) collect m do (setf pos p))
22:11:19
bbsl
_death: yes I have a feeling that knowing how to use setf propperly would be a big boon. I am borking stuff trying to shoehorn my usual goto of returning tuples
22:11:49
phoe
bbsl: in order to learn how SETF works, I'd start with learning how places work and what they are
22:15:48
bbsl
phoe: not realy I started reading Practical Common Lisp but I started jumping around after the author went all in on the global `database` state nonsense
22:17:11
Xach
Practical Common Lisp is a good book and you will learn a lot from it if you read it carefully.
22:21:03
phoe
the initial chapter is there to give you an overall feeling of how working with the language looks like,.
22:21:20
phoe
I've always thought that this is the missing sentence that should have been printed in bold text at the beginning of PCL chapter 2
22:21:37
phoe
because people try to read it and assume that they need to follow *EVERYTHING* that this chapter is about
22:23:17
bbsl
well I lost interest trying to get trough that chapter. Wish there was a better resource like 'learn you a Haskell' but I guess I will pick the book up again in a while
22:24:27
phoe
for about a year now, I have consistently been not sure whether chapter 2 of PCL in its current form is not a mistake
22:25:49
phoe
sure, but not everyone has the background to understand the technical parts and/or the attitude to just sit back and enjoy the ride instead of trying to understand everything that is going on
22:27:52
Shinmera
people have preferences. whether they'll like it or not you can't know until they've tried reading it.
22:40:58
bbsl
you should glance at the 'learn you a haskell' or the rust book, both are easyer to read with less fluff imo. compared to those Id say the Practial Common Lisp book is pretty lackluster but I guess they are two different sets of books to be fair
22:43:11
fengshaun
how can I pass <place> designator (e.g. used for setf) to functions? is it only doable with macros?
22:43:33
fengshaun
and just leave the place specifier as unevaluated until passed to whatever function/macro that needs it?
22:43:59
White_Flame
a place designator is a syntactic thing, so yes it's in the domain of macros if you pass it around
22:45:58
White_Flame
say for car, (defun car-locative (cons) (list (lambda () (car cons)) (lambda (val) (setf (car cons) val))))
22:46:36
White_Flame
(defmacro make-locative (place) (list (lambda () ,place) (lambda (val) (setf ,place val))))
22:51:06
White_Flame
where it had its own type and specific get/set functions into data it pointed to
22:51:34
White_Flame
but yeah, wrapping a place in a getter/setter function offers the same sort of interface, but you can actually access anything, even bits within a byte
22:52:14
White_Flame
slot = a variable binding location, an element of a struct/class instance/array, the car or cdr of a cons, etc
22:53:11
White_Flame
not knowing where you are with things, #clschool is a bit more newbie friendly, while #lisp assumes a lot more :)
23:02:25
moon-child
what's the best way to do gui in cl, barring lispworks? I saw eql, which seems to be ecl-specific; commonqt, which is still on qt4; a bunch of interfaces to tk, which apparently some people think is ugly; and a binding to gtk, which apparently looks ugly on macos and windows
23:04:23
moon-child
phoe: yeah. I don't want to be relying on a framework which isn't going to be maintained in the future
23:04:45
moon-child
jasom: really, huh, didn't know that. Theming like gtk where it's a user-applied theme, or can I make it look good from within the application?
23:05:04
jasom
moon-child: yes to both, but it's not popular enough for many people to have a user-applied theme
23:05:29
phoe
moon-child: really annoying bugs tend to sometimes get backported into qt-libs that commonqt can use
23:07:32
moon-child
I know someone made qt5 bindings for d, going through a c layer, so it's definitely possible
23:07:33
jasom
If you're willing to write your GUI in C++ and export out hooks to call into lisp, you could make a dynamically loadable library that lisp could call.
23:09:03
moon-child
I don't think it'd be worth it for me; it's not going to be a ui-heavy app. Just would be nice to use a nicer lib if it were possible
23:09:44
jasom
moon-child: D did it by making a generic DLL with bindings (QtE5Widgets) I suppose we could use that DLL from common lisp.
23:10:58
jasom
Of course I don't know if it has foreign bindings or not; it might be D specific (D can generate DLLs)
23:11:53
moon-child
d also is able to call directly into c++, which idk if they're using that at all
23:12:56
moon-child
yep. But most people don't use it because there isn't a good automatic binding generator and there are some unimplemented features. So if they're going through an intermediate dll, there's a good chance they're not using it
23:13:37
jasom
generateAlias("t_v__qp_qp_i_i_i_i_i") <-- looks like they could be using it, that looks like a C++ mangled name
23:13:39
moon-child
(aside: cl could call into qte5's c library, instead of needing to create our own. Be an annoying dependency but ¯\_(ツ)_/¯)
23:16:32
moon-child
jasom: nope. generateAlias() makes an extern(C) function, meaning c ABI and name mangling
23:17:33
moon-child
phoe: dependency on a d library is less practical than a dependency on a c|c++ library
23:22:25
jasom
moon-child: Python extsnsions are usually written in any language that can export C functions; there is a C api that allows manipulation of python objects.
23:22:38
jasom
It looks like Go's bindings might be usable: https://github.com/therecipe/qt/blob/master/gui/gui.h
23:24:15
moon-child
This issue https://github.com/ryanmelt/qtbindings/issues/131 mentions an updated version of smoke
23:57:25
lottaquestions
Hi all, I have a question about SLDB with SBCL. How does one know which frames can be restarted and which ones cannot? Also, I seem to be losing global variables when I restart frames. I how do I prevent against that?
0:38:05
dmiles
White_Flame: the real power of the locative is not what it sets.. it what it makes appear in several locations
0:40:28
White_Flame
if locatives were somehow transparently traversed, then it would have such magic effects, but probably be unworkable
0:40:44
dmiles
yeah i wanted to actualyl that it is really is about structure sharing.. to be ablke to have a CDR withotu a CONS
0:41:34
White_Flame
yeah, for purely CONS-based stuff, having a cdr iterator function instead of just a data link would be somewhat interesting
0:42:47
White_Flame
again, the main difference is if diverting pointers or accessors would be followed implicitly, instead of requiring dereferencing them manually/specifically
0:43:18
dmiles
( i was really tryign to say .. "to have structure sharing yet evenb when no structrures exist)
0:48:57
dmiles
since nowadays you have to find all 5 places and trrhe symbol value and if any one is set you have to go and update the otehr 5
0:50:05
White_Flame
while it "wastes a slot" it's less usually memory footprint & code than a 1-element structure or array
0:51:19
dmiles
what ECL used to have is a brilliant dynanmic extent on locatives that merely could forget about them or not
1:40:31
akoana
Xach: probably it is included in the hspell package (I did apt-get source --download-only hspell, there is a libhspell.c in the orig.tar.gz)