<kristofer>I'm trying to understand how to use (sort-list list less) -- what is less supposed to be? <ft>A function of two arguments that tells sort how to sort. <ft>or something more complicated, depending on what you are trying to sort. <ft>(sort-list (list "bde" "def" "abd" "123") string<) <ft>and for fun, exchange string< with string> <kristofer>okay, so I have (sort-list (string->list "some random string") string<) <kristofer>wrong type argument in position 1 (expecting string) #\\r <ft>What do you think string->list does? <kristofer>I'm guessing string->list isn't a list of strings <ft>at the REPL do: ,d string->list <kristofer>right I understand, char< is unboundvariable though <ft>it's char<? in that case <kristofer>sorry, the tab-completion was working with char<?, I just didn't trust it <ft>The question mark is supposed to remind the reader that a question is being asked. <ft>And since question marks are fair game in scheme symbols, that's something that's done. ☺ <kristofer>I guess I mean, why in the string< case there is no '?' <ft>There is "string<?" as well. <ft>In an ideal world, this would be less confusing. ☺ <kristofer>is the % symbol special, or fair game as well <mark_weaver>R5RS included "?" in the string comparators, and SRFI-13 left them out. Many people have had a hand in the design of various APIs used in the Scheme world, and so some consistently has been lost along the way :) <ft>% is fair game as well. Though guile uses some %foo parameters for internal use. <ft>Actually, in guile you can even have spaces in symbol names: (string->symbol "foo bar") — but I guess in normal use that would be a bit of a no. ☺ <davexunit>any character you can use in a string, you can use in a symbol <ft>Yeah, but any time the symbol ends up as #{foo bar}# at the REPL, I feel dirty. ☺ <davexunit>you wouldn't want to write symbol literals like that, but it's nice that symbols support the full range of characters <paroneayea>maybe symbols can be anything, though guile supports 42-the-big-answer <paroneayea>and mark_weaver pointed out to me that (8sync) would be an invalid for a strict r6 / r7 reader... <paroneayea>and doesn't look confusingly like a global variable thing. <davexunit>there's no way that your code is portable to other Schemes <paroneayea>it does mean suffering seeing #{8sync}# at the REPL though <paroneayea>it's a macro though so I guess you don't see it much anyway at the REPL :) <daviid>glad guile support '8sync :) [and gdk-event like 2button, 3button ...] otherwise we would have had to parse these before to bind ... what a nightmare ... :) <paroneayea>the real debate was whether to have eightsync for the module namespace or 8sync <xyh>who made a joy [the language] in guile ? <xyh>my question is how do you implemented ifte combinator ? <amz`>I'm wondering where to go from here <amz`>I waiting for probKanren, but it the mean time, I see only road blocks for a change <amz`>by the way, I tried to implement a Chat bot, but it was too simplistic, in a similar fashion to sneek <amz`>I'm wondering how to go beyond symbolic AI <csed>amz`: So Paradigns of AI Programming gets you started with rule based in like, the introduction. <csed>Might also wanna look up situational calculus. ***hesiod_ is now known as hesiod
***karswell` is now known as karswell
<amz`>is there any interest in using swig for a C code base to create guile bindings? <mark_weaver>amz`: IMO, it would be better to use the Dynamic FFI going forward. ***xyh_ is now known as xyh
<Jookia1>What's the idiomatic way to pass functions to functions? Is this even possible? <davexunit>procedures are just a value, pass them around as you please. <davexunit>a procedure that takes a procedure as an argument or returns a procedure is called a higher-order procedure. <Jookia1>I don't know why I didn't think that'd be the case :P <Korhonen>You can also store functions in the value-cell in common lsip can't you? <Korhonen>can you store values in the function-cell? <Jookia1>I've never used any Lisp but Guile, mostly Haskell <Jookia1>For some reason I was thinking that you'd need to serialize the function which makes no sense <Korhonen>And really most modern languages that realized that is the way to go. <Korhonen>I find it interesting how often nowadays you in Scheme see (define (function xs) ...) instead of the older (define (function lst) ...) <Korhonen>davexunit, yes, but what kernel do you run. <Korhonen>davexunit, no, I mean the version, the speciics <Korhonen>Like what scheduler, what's your config. <davexunit>I don't understand how this relates to the current topic <Korhonen>Not much I guess, I was just suddenly curious so decided to ask. <davexunit>but I'm not at my own computer right now so not sure precisely <amz3>Korhonen: why are you curious? <amz3>Korhonen: I'm curious :troll-face: <Korhonen>Not every kernel exposes /proc/config.gz <Korhonen>I guess because I'n currently compiling my new kernel and I'm just curious what others have <kristofer>hey ya'll! what's the ideal module to build a tree structure with guile? <kristofer>I'm building anagrams with a list of english words. I think I can do some more powerful searches with a tree of words vs the list I'm working with now. <davexunit>or use your own data type that has "child" nodes <Korhonen>I would personally build a tree from records though and enforce the proper data structure. <Korhonen>I was never a fan to begin with that lists in Scheme by historical reason are "ad hoc" and list? does not run in consistent time. <Korhonen>In Scheme 2.0, they would probably do best to have cons enforce that its second argument be either another cons sell or the empty list and make list? basically test pair? or null? <davexunit>if we did what you suggested, then a lot of uses for pairs wouldn't be possible, such as alists. <Korhonen>davexunit, well, records exist nowadays for that. <davexunit>records are good for plenty of things, but pairs are still useful. <Korhonen>I mean, call it what you like, it doesn't need to be called a part, I'm just saying that like in most languages list? should run in constant time and enforce that it is always a list. <davexunit>that's just not you do it in Scheme, though. <Korhonen>Well, I take it we can agree that usually mutably transforming a list to a non proper list is considered a symptom of something being very wrong. <davexunit>you usually ask null? to check for the empty list <Korhonen>Well, that you don't is a problem, functions like "map" and "exists" etc in the standard library have unspeciied behaviour essentially when the argument is not a proper list <Korhonen>Because running list? does not run in constant time. <Korhonen>Yeah, but what happens if you pass an improper list to all those functions or some other data structure composed of pairs? <Korhonen>Ideally you want those functions to just b able to reject that immediately. <Korhonen>THere's a difference between dynamic typing and duck typing. <Korhonen>And lists are the only place where scheme uses duck typing <Korhonen>And it would not if list? ran in constant time, it's a concession, not a conscious choice. <Korhonen>If you pass a non string to a function expecting a string it errors right there <davexunit>we'll just have to agree to disagree on this <davexunit>pairs behaving as they are fundamental to lisp. <mark_weaver>the original idea in lisp and scheme was that pairs were sufficient to build any data type at all, and some people still do it that way. <Korhonen>To scheme and common lisp at best, clojure uses the approach I outlined. <Korhonen>Yeah, but nowadays that's consideed back practice and records are typically used. <mark_weaver>but a large portion of the scheme community has abandoned that idea, for better or for worse. <Korhonen>Well, I would say for better, being able to verify in constant time whether something is that type guaranteed is very handy. <davexunit>records are great and I use them all the time, but I'm cool with lists as-is <Korhonen>davexunit, hmm, so say you would have to repraesent a complex number for somehing, would you just use a pair? <Korhonen>Or say a point in 2 space because complex numbers are built in <Korhonen>So what would you use pairs for when not used for lists? <mark_weaver>Korhonen: btw, do you have a concrete suggestion of how we could improve things? <mark_weaver>in a way that doesn't destroy compatibility with huge amounts of existing code? <Korhonen>mark_weaver, well, not within the current scheme, hence I said Scheme 2.0, if we were allowed to start over, I would get a list? type that runs in constant time whose "cons" enforces that its second element be a list. <Korhonen>I mean, I understand the ship has sailed now and it can't be changed any more at this point. <Korhonen>But I often find myself just writing code using pairs basically _only_ for lists as a rule and just use pair? | null? as list? and use records for all the other things. <Korhonen>But to be fair, this is more ranting about the little things in languages that frustrate me if anything than being really constructive, I know it's never going to happen but it's a thorn all the same. <Korhonen>I rant a bit too much about small perfections maybe. <mark_weaver>I guess my perspective is that even the most sophisticated type system can't detect all errors up-front anyway. <mark_weaver>so I don't see it as a fundamental problem that I can't rule out the possibility of an improper list ahead of time. <Korhonen>It's always a matter of degrees though, you might as well have no tags any more then. <Korhonen>IT's not a fundamental problem no, but a small imperfection all the same. <mark_weaver>I view it as a tradeoff rather than a clear imperfection <Korhonen>THe only advantage I see is being able to transform proper lists into improper lists with cdr-set! which is not something I can imagine ever being useful. <mark_weaver>I think the idea was to create the simplest possible mechanism to create any data structure you might want. <Korhonen>circular lists can also be made with this type, though I would argue that circular lists probably need their own type as well. <Korhonen>Yeah, but even so, it's not even that convenient for say creating a vector of four values. <mark_weaver>making circular lists their own distinct type means either having to duplicate a lot of list procedures or else having almost no tools with which to deal with circular lists. <Korhonen>I don't see why, the tools that work on circular lists can accept both list? and circular-list? those that don't work on circular lists can immediately reject them without diverging. <Korhonen>Or diverge all the same with say find if that's considered acceptable if it's not in the circle. <mark_weaver>I'm sorry, I don't have time to continue this discussion right now.