laurent.orseau
2020-8-2 07:38:46

Like adjacent-remove-duplicates doesn’t exist either, despite being O(n) for sorted lists, vs O(n^2) for remove-duplicates


laurent.orseau
2020-8-2 07:42:06

Does your function check the arity of the input function to know how to group? You seem to use it with a unary predicate and with a binary function


sorawee
2020-8-2 08:07:22

Predicate as in it it’s used to determine true/false? No.


sorawee
2020-8-2 08:07:57

It is the case for the first example, where there are “two groups” because char-whitespace? returns either #t ot #f


sorawee
2020-8-2 08:08:17

But for the second example, the output is any number


sorawee
2020-8-2 08:08:39

So what’s required in the first argument is any function of arity one.


sorawee
2020-8-2 08:09:04

Probably possible to extend that to more than one


sorawee
2020-8-2 08:09:27

I’m also not sure what you mean by binary function.


sorawee
2020-8-2 08:09:44

There probably should be an optional argument for the sameness function


sorawee
2020-8-2 08:10:06

Defaulting to equal? which is what I use in the above two examples.


laurent.orseau
2020-8-2 08:21:22

Ok, makes all sense now :slightly_smiling_face:


laurent.orseau
2020-8-2 08:36:02

Sounds like you could have a similar interface as sort, with an extract-key and a comparator. There are quite a number of functions that have the same interface (such as my proposal for best ), we should try to use a unified interface.


laurent.orseau
2020-8-2 08:38:45

If we align with sort, that would be: (define (adjacent-group-by lst comparator #:key [extract-key values])...) but it doesn’t make too much sense here, so maybe we should have a more general interface like: (define (fun lst #:key [extract-key values] #:comparator [cmp equal?] #:cache-keys? [cache? #f]) ...) where the default arguments could of course change depending on the function


laurent.orseau
2020-8-2 08:53:34

A findf function could also use this interface


notjack
2020-8-2 08:57:00

a transducer-based version is possible if I ever get around to finishing https://github.com/jackfirth/rebellion/pull/331, which adds a grouping-consecutive transducer


sorawee
2020-8-2 08:57:41

nice!


notjack
2020-8-2 08:57:47

(transduce "abc def ghi" (indexing char-whitespace?) (grouping-consecutive into-list) #:into into-list)



laurent.orseau
2020-8-2 08:58:58

yes, this one too


laurent.orseau
2020-8-2 08:59:34

We should use the comparators in data/order


notjack
2020-8-2 09:00:00

Can there be a sequence-chaperone function? Is that possible to add?


sorawee
2020-8-2 09:00:01

Keep in mind that the word comparator has several variants


notjack
2020-8-2 09:00:12

I usually assume the Java one


laurent.orseau
2020-8-2 09:00:56

What would that do?


notjack
2020-8-2 09:01:27

let me add a guard around each element like with sequence-map, but without changing the underlying type of the sequence so it returns a sequence that’s equal? to the original


sorawee
2020-8-2 09:01:58

The one in sort returns a boolean, not reflexive.

The one in C++ returns an integer.

The one in group-by returns a boolean, reflexive and symmetric.


laurent.orseau
2020-8-2 09:02:05

Re comparators, sometimes the use is for total order, sometimes is just for = or not =. I’m hoping we can use data/order for both


notjack
2020-8-2 09:02:57

I usually use “comparator” to mean “thing that can tell you which of two values is bigger”, and “equivalence relation” to mean “thing that can tell you if two values are the same”


laurent.orseau
2020-8-2 09:04:28

Is this for mutable sequences? Not sure what the guard would be for.


notjack
2020-8-2 09:05:16

Like, (sequence/c number?) should be a chaperone contract. It’s currently an impersonator contract, even though there’s no real reason it needs the ability to impersonate the original sequence.


sjaniska
2020-8-2 09:06:25

hello, is there any gui app written in Racket like https://github.com/alex-hhh/ActivityLog2? i’m considering Racket for (multi-platform) desktop app and weighting it against some statically-compiled languages like Nim…


laurent.orseau
2020-8-2 09:06:25

I was thinking you can overload equal? and encapsulate in a struct maybe?


laurent.orseau
2020-8-2 09:07:00

@spdegabrielle Did you keep track somewhere of the gui apps out there?


laurent.orseau
2020-8-2 09:07:31

@sjaniska You can start searching for gui on the list of packages: https://pkgd.racket-lang.org/pkgn/search?q=gui


laurent.orseau
2020-8-2 09:07:58

(not everything is relevant of course)


notjack
2020-8-2 09:08:03

implementations of gen:equal+hash aren’t consulted unless both values are of the same struct type, so although I could make a (struct chaperoned-sequence (original guard) …) type, I wouldn’t be able to get it to compare equal? to original.


laurent.orseau
2020-8-2 09:08:48

A few of mine: mred-designer, color-flood, towers-gui


laurent.orseau
2020-8-2 09:09:17

Yeah, I thought that would be the case :confused:


notjack
2020-8-2 09:09:51

regrettably, I think the only way to make this work would be to add some sort of optional method for chaperoning to the sequence interface and allow implementations to provide it


sjaniska
2020-8-2 09:15:25

do you consider thar set of widgets is rich-enough for “general” gui apps?


poga.po
2020-8-2 10:04:07

@poga.po has joined the channel


laurent.orseau
2020-8-2 10:48:42

Yes, but sometimes you have to derive the class to override some methods, for example to react to key presses


laurent.orseau
2020-8-2 10:49:45

Mred-designer is a gui builder btw



spdegabrielle
2020-8-2 11:19:40

@sjaniska a list would make a good wiki page - please post any here and I’ll do it this evening


samth
2020-8-2 13:12:26

Also, in case it isn’t clear, DrRacket is a cross platform GUI app written in Racket. There are also several as part of the games package.


samth
2020-8-2 13:13:43

I think it’s possible. You’d have to extend the sequence interface, though, since individual sequence types would have to implement it themselves.


laurent.orseau
2020-8-2 13:23:06

Otherwise you can attach the desired properties through a hashtable, so that eq? doesn’t change, but then it’s the burden of the callees to check the table for the guard


sjaniska
2020-8-2 16:56:56

I know about DrRacket and I must say that having well-support built-in GUI DSL is tempting feature in comparison with some other language where GUI bindings are usually one-man show, not well supported etc. which makes those (statically-compiled) languages less attractive in comparison with Racket. Imho, Racket’s GUI is not popularized well-enough…


spdegabrielle
2020-8-2 17:05:51

I wish I knew the distribution of software engineering; 1 software dev companies 2 companies that software is their business but don’t distribute/sell (FAANGs) 3 companies that do other things but code is written every day to keep the business going (i work for a hospital!)


sjaniska
2020-8-2 17:40:46

@spdegabrielle you’re using Racket?


sjaniska
2020-8-2 17:41:30

(for the hospital work)


spdegabrielle
2020-8-2 18:18:55

No


spdegabrielle
2020-8-2 18:19:07

I’m not using Racket at work


sorawee
2020-8-2 20:56:38

Racket CS has one cool capability. It allows us to convert non-negative integer to English text easily


sorawee
2020-8-2 20:56:54

(define (calc s) (second (regexp-match #px"returned (.*?) values to single value return context" s))) (define (number->english-string n) (define out (with-handlers ([exn:fail? (lambda (e) (calc (exn-message e)))]) (values (apply values (range 0 n))))) (if (eq? out 0) "one" out)) (number->english-string 0) (number->english-string 1) (number->english-string 2) (number->english-string 100)