Re: [Chicken-users] two procedures looking for a good home

2008-02-24 Thread Alejandro Forero Cuervo
 If redundancy were a reason for deleting egg functionality, we have
 about seven object systems to get rid of. ;-)

Ah, but if you pick any two of those, they will have their
differences!

In this case, however, *absolutely* all usages of the new code are
supported by the old one and it is *impossible* for a user to find any
difference between them (other than the fact that orders' function is
called cmp-key and the combinator's make-/key) no matter how hard
they try.

IMHO case that should be enough of a reason not to add the copy of the
code in another egg with a different name.

Alejo.
http://azul.freaks-unidos.net/


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] two procedures looking for a good home

2008-02-24 Thread Graham Fawcett
On Sun, Feb 24, 2008 at 1:16 PM, Alejandro Forero Cuervo
[EMAIL PROTECTED] wrote:
  If redundancy were a reason for deleting egg functionality, we have
   about seven object systems to get rid of. ;-)

  Ah, but if you pick any two of those, they will have their
  differences!

  In this case, however, *absolutely* all usages of the new code are
  supported by the old one and it is *impossible* for a user to find any
  difference between them (other than the fact that orders' function is
  called cmp-key and the combinator's make-/key) no matter how hard
  they try.

No worries, I was just joking. :-) I agree, the redundancy is
pointless. It's pointless, I say.

I'd like to add a (sort/decorated lst cmp key) proc to your orders
egg, that calculates the key values only once; this can be more
efficient than (sort ... (cmp-key ...)) for cases where key generation
is expensive. I think it fits in your egg; are you OK with that?

(The name 'decorated' is an allusion to the 'decorate-sort-undecorate'
idiom in Python, which this replicates; we can rename to something
more clear.)

Graham


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] two procedures looking for a good home

2008-02-24 Thread Alejandro Forero Cuervo
 No worries, I was just joking. :-) I agree, the redundancy is
 pointless. It's pointless, I say.

Ahh, hahahahah, I thought you were serious.  Sowwy.

 I'd like to add a (sort/decorated lst cmp key) proc to your orders
 egg, that calculates the key values only once; this can be more
 efficient than (sort ... (cmp-key ...)) for cases where key generation
 is expensive. I think it fits in your egg; are you OK with that?

You are still joking here, right?

(See the sort-key-cache function in said egg.) ;-)

Heheh.

Alejo, feeling very redundant with Graham today. :-)
http://azul.freaks-unidos.net/


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] two procedures looking for a good home

2008-02-24 Thread Graham Fawcett
On Sun, Feb 24, 2008 at 1:55 PM, Alejandro Forero Cuervo
[EMAIL PROTECTED] wrote:
   I'd like to add a (sort/decorated lst cmp key) proc to your orders
   egg, that calculates the key values only once; this can be more
   efficient than (sort ... (cmp-key ...)) for cases where key generation
   is expensive. I think it fits in your egg; are you OK with that?

  You are still joking here, right?
  (See the sort-key-cache function in said egg.) ;-)

D'oh, no I wasn't joking that time, I just hadn't read the whole egg
properly. Funny. :-)

  Alejo, feeling very redundant with Graham today. :-)

Heh. I am fighting a cold today; I didn't think it was impairing my
judgment, but I think I was wrong...

Best wishes,
Graham





 http://azul.freaks-unidos.net/



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] two procedures looking for a good home

2008-02-21 Thread Graham Fawcett
On Thu, Feb 21, 2008 at 3:26 PM, Kon Lovett [EMAIL PROTECTED] wrote:
   I find that I use these two procedures frequently, and I'd love to see
   them in an egg so I don't need to keep including them locally. Perhaps
   is someone interested in working on a shared misc-combinators egg, to
   store handy little things like this?
  Done. See release/3/combinators. Ignore the License stuff, much of
  this is automatically generated boiler-plate.

Damn, Kon, you are fast!

This is the clinching evidence supporting my theory that you are actually a bot.

Thanks, konbot,

G


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] two procedures looking for a good home

2008-02-21 Thread Alejandro Forero Cuervo
 (define (key-on proc #!optional (comparator ))
   ;; Define a comparator function for a sort. E.g. to sort a list of
   ;; lists by their first items, using string-case-insensitive
   ;; comparison: (sort lst (key-on first string-ci?))
   (lambda (a b) (comparator (proc a) (proc b

This sounds very similar to the under-documented cmp-key function in
the orders egg:

 (define (cmp-key cmp key)
   (lambda args (apply cmp (map key args

The orders egg provides some convenience wrappers around this.

Any help documenting that egg would be appreciated. :-)

Alejo.
http://azul.freaks-unidos.net/


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] two procedures looking for a good home

2008-02-21 Thread Kon Lovett


On Feb 21, 2008, at 12:15 PM, Graham Fawcett wrote:


Hi folks,

I find that I use these two procedures frequently, and I'd love to see
them in an egg so I don't need to keep including them locally. Perhaps
is someone interested in working on a shared misc-combinators egg, to
store handy little things like this?

If such an egg exists and I'm not aware of it, please let me know.

Graham

(define (group-by keyproc lst #!optional (is-equal equal?))
  ;; group a list of elements by some key attribute.
  ;; the list must be in sorted order with respect to the key.
  ;; examples:
  ;; (group-by identity '(1 2 3 3 4 4 4)) -- ((1) (2) (3 3) (4 4 4))
  ;; (group-by car '((a 1) (a 2) (b 1))) -- '(((a 1) (a 2)) ((b 1)))
  (let loop ((lst lst) (acc '()))
   (if (null? lst)
   (reverse acc) ;; possibly remove the reversal?
   (let ((key (keyproc (car lst
 (receive (grouped rest)
 (span (lambda (item) (is-equal key (keyproc item))) lst)
   (loop rest (cons grouped acc)))

(define (key-on proc #!optional (comparator ))
  ;; Define a comparator function for a sort. E.g. to sort a list of
  ;; lists by their first items, using string-case-insensitive
  ;; comparison: (sort lst (key-on first string-ci?))
  (lambda (a b) (comparator (proc a) (proc b



Done. See release/3/combinators. Ignore the License stuff, much of  
this is automatically generated boiler-plate.




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Best Wishes,
Kon




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users