[plt-scheme] no mappend! in scheme/mpair?

From: John Clements (clements at brinckerhoff.org)
Date: Mon Jan 14 18:24:28 EST 2008

On Jan 14, 2008, at 12:06 PM, Matthew Flatt wrote:

> At Mon, 14 Jan 2008 11:59:22 -0800, John Clements wrote:
>> I would think that the principal use of mpairs would be to allow
>> programmers to use existing mutable-pair code, including append! and
>> reverse!.  However, I don't see an mappend! or mreverse!.  Is their
>> omission an oversight, or is there some good reason not to have them?
>
> No good reason. They're missing only because the `scheme/mpair'  
> library
> was originally created to support `r5rs'.
>
> Please feel free to add `mappend!' and `mreverse!' and update the  
> docs.

I added mappend! (& docs), but not mreverse!.  I spent five minutes  
looking for a place to hang test cases and gave up. I'm sure they're  
in there somewhere.  Instead, I attach a set of test cases written  
using 'equal?', in the hopes that they will magically wind up in a  
good place.

Thanks,

John


#lang scheme/base

(require scheme/mpair)

;; no args
(equal? (mappend!) null)
;; one arg
(equal? (mappend! (mlist 3 4 5)) (mlist 3 4 5))
;; two args
(equal? (mappend! (mlist 3 4) (mlist 5 6)) (mlist 3 4 5 6))
(define a (mlist 3 4))
(equal? (mappend! a (mlist 5 6)) (mlist 3 4 5 6))
(equal? a (mlist 3 4 5 6))
(equal? (mappend! null (mlist 3 4 5)) (mlist 3 4 5))
;; three args
(equal? (mappend! (mlist 3 4) (mlist 5 6) (mlist 7 8)) (mlist 3 4 5 6  
7 8))
(equal? (mappend! (mlist 3 4) null (mlist 5 6)) (mlist 3 4 5 6))
(define a2 (mlist 3 4))
(equal? (mappend! null a2 null (mlist 5 6)) (mlist 3 4 5 6))
(equal? a2 (mlist 3 4 5 6))
(define a3result (mcons 3 'bogus))
(set-mcdr! a3result a3result)
(define a3 (mlist 3))
(equal? (mappend! a3 a3) a3result)
(equal? a3 a3result)




Posted on the users mailing list.