IRC channel logs


back to list of logs

<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>like <
<ft>or string<
<ft>or something more complicated, depending on what you are trying to sort.
<kristofer>just a string
<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>ha! why append the '?'?
<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>like %load-path
<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. ☺
<paroneayea>ACTION feels dirty when he sees that too :)
<davexunit>you wouldn't want to write symbol literals like that, but it's nice that symbols support the full range of characters
<paroneayea>yes it is nice that Guile supports it!
<davexunit>I believe its standard Scheme
<paroneayea>davexunit: nope
<paroneayea>at least not in the reader
<paroneayea>maybe symbols can be anything, though guile supports 42-the-big-answer
<davexunit>any valid string is a valid symbol
<paroneayea>and mark_weaver pointed out to me that (8sync) would be an invalid for a strict r6 / r7 reader...
<paroneayea>%8sync is fine though
<paroneayea>hence the %
<paroneayea>maybe I should just drop it though
<paroneayea>and leave %8sync as an alias
<paroneayea>(8sync (foo)) looks nicer.
<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>davexunit: yeah
<davexunit>prompts and such
<paroneayea>it does mean suffering seeing #{8sync}# at the REPL though
<paroneayea>poor 8sync is behind bars!
<paroneayea>it's a macro though so I guess you don't see it much anyway at the REPL :)
<davexunit>the form could maybe use another name
<paroneayea>now I remember
<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
<paroneayea>I think ArneBab convinced me to do 8sync
<paroneayea>wise move!
<paroneayea>I really need to get back to 8sync
<paroneayea>too may spinning plates..
<daviid>i voted 8sync too! hehe
<paroneayea>hey speaking of spinning plates, I know davexunit saw, but maybe others didn't
<paroneayea>not guile related but GNU related
<davexunit>paroneayea: it's very cool :)
<nalaginrut>morning guilers~
<amz3>héllo :)
<xyh>who made a joy [the language] in guile ?
<xyh>I forget the nick
<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`>so I abandonned
<amz`>I'm wondering how to go beyond symbolic AI
<amz`>aka. Rule based 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
<dsmith-work>Morning Greetings, Guilers
***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?
<Jookia1>I see now
<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>Because Common Lisp is idiotic, maybe.
<Korhonen>You can also store functions in the value-cell in common lsip can't you?
<Korhonen>THat makes it all the quainter
<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
<amz3>thx mark
<Korhonen>Well no, it is quite like Haskell here.
<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>THat xs convention of Hasell caught on
<davexunit>I've never seen that
<Korhonen>davexunit, yes, but what kernel do you run.
<davexunit>Korhonen: linux-libre
<davexunit>ACTION is confused
<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
<Jookia1>Is this meant for #guix
<Korhonen>davexunit, hmm.
<Korhonen>Not much I guess, I was just suddenly curious so decided to ask.
<Korhonen>Can I see your kernel config?
<davexunit>I don't know where to find that
<davexunit>I'm just running 4.4.1 I think
<Jookia1>zcat /proc/config.gz
<davexunit>but I'm not at my own computer right now so not sure precisely
<amz3>Korhonen: why are you curious?
<Jookia1>It's stock Guix config I'd guess
<Korhonen>Probably in /boot/config-4.4.1 I think
<amz3>Korhonen: I'm curious :troll-face:
<Korhonen>Not every kernel exposes /proc/config.gz
<Korhonen>amz3, hmm
<Korhonen>I guess because I'n currently compiling my new kernel and I'm just curious what others have
<Korhonen>Well, I just compiled it.
<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>kristofer: you can build a tree from lists
<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>that doesn't make sense.
<davexunit>a pair can store any 2 elements
<davexunit>they aren't just for lists
<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 never really ask that question
<davexunit>you usually ask null? to check for the empty list
<davexunit>or you use a pattern matcher
<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?
<davexunit>you'll get an error
<Korhonen>Ideally you want those functions to just b able to reject that immediately.
<davexunit>this isn't a statically typed language
<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
<davexunit>a list isn't a type, though.
<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
<davexunit>no I would use a record.
<Korhonen>Yes, as would I
<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?
<davexunit>key/value mappings
<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>What's the advantage?
<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>what about circular lists?
<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>Or at least "unbounded lists"
<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.
<Korhonen>That's fine.