unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Appending Queues
@ 2012-10-28 19:59 Noah Lavine
  2012-11-02 17:20 ` Ian Price
  0 siblings, 1 reply; 4+ messages in thread
From: Noah Lavine @ 2012-10-28 19:59 UTC (permalink / raw)
  To: guile-devel

Hello,

I was just working on a project that used (ice-9 q), and I found that
I needed to append two queues. I wrote the following functions to do
it. What do you think of including them in (ice-9 q)? It's pretty
simple, but it seems like a natural part of the queue interface. I've
included destructive and non-destructive versions.

The only change I was considering is allowing an arbitrary number of
arguments, but that's something I can implement if people agree that
we want the functions in (ice-9 q).

(define (append-qs q r)
  (cons (append (car q) (car r)) (cdr r)))

(define (append-qs! q r)
  (set-cdr! (cdr q) (car r))
  (set-cdr! q (cdr r))
  q)

Thanks,
Noah



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Appending Queues
  2012-10-28 19:59 Appending Queues Noah Lavine
@ 2012-11-02 17:20 ` Ian Price
  2012-11-02 18:00   ` Noah Lavine
  2012-11-02 22:11   ` Ludovic Courtès
  0 siblings, 2 replies; 4+ messages in thread
From: Ian Price @ 2012-11-02 17:20 UTC (permalink / raw)
  To: Noah Lavine; +Cc: guile-devel

Noah Lavine <noah.b.lavine@gmail.com> writes:

> The only change I was considering is allowing an arbitrary number of
> arguments, but that's something I can implement if people agree that
> we want the functions in (ice-9 q).

I'm loath to add anything to (ice-9 q) since I find the names, and
the lack of a distinct type, less than satisfactory.

However, if you are going to add them, I'd recommend sticking with the
q- prefix. So, q-append and q-append!. Keeping the naming consistent
means one less exception to remember.

Also, I think it might be wise to add a list->q and q->list, with the
obvious simple implementations

(define (q->list q)
  (car q))

(define (list->q l)
  (if (null? l)
      (make-q)
      (cons l (last-pair l))))

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Appending Queues
  2012-11-02 17:20 ` Ian Price
@ 2012-11-02 18:00   ` Noah Lavine
  2012-11-02 22:11   ` Ludovic Courtès
  1 sibling, 0 replies; 4+ messages in thread
From: Noah Lavine @ 2012-11-02 18:00 UTC (permalink / raw)
  To: Ian Price; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 747 bytes --]

Hello,

On Fri, Nov 2, 2012 at 1:20 PM, Ian Price <ianprice90@googlemail.com> wrote:
>
> I'm loath to add anything to (ice-9 q) since I find the names, and
> the lack of a distinct type, less than satisfactory.
>

Fair enough. I'd be just as happy to implement a new queue container. I
think we need to keep (ice-9 q) around for compatibility, though, so I'm
tempted to say we should go ahead and make it as good as it can be.


> However, if you are going to add them, I'd recommend sticking with the
> q- prefix. So, q-append and q-append!. Keeping the naming consistent
> means one less exception to remember.
>
> Also, I think it might be wise to add a list->q and q->list, with the
> obvious simple implementations
>

You're right. :-)

Noah

[-- Attachment #2: Type: text/html, Size: 1279 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Appending Queues
  2012-11-02 17:20 ` Ian Price
  2012-11-02 18:00   ` Noah Lavine
@ 2012-11-02 22:11   ` Ludovic Courtès
  1 sibling, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2012-11-02 22:11 UTC (permalink / raw)
  To: guile-devel

Hi,

Ian Price <ianprice90@googlemail.com> skribis:

> Noah Lavine <noah.b.lavine@gmail.com> writes:
>
>> The only change I was considering is allowing an arbitrary number of
>> arguments, but that's something I can implement if people agree that
>> we want the functions in (ice-9 q).
>
> I'm loath to add anything to (ice-9 q) since I find the names, and
> the lack of a distinct type, less than satisfactory.

+1.  And there are functional queue implementations around that are
worth promoting, IMO.

Ian: would you like to turn (pfds queues) into a patch against Guile?
:-)

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-11-02 22:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-28 19:59 Appending Queues Noah Lavine
2012-11-02 17:20 ` Ian Price
2012-11-02 18:00   ` Noah Lavine
2012-11-02 22:11   ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).