Could you export from (match) library match+ and trace-match+

Bug #301612 reported by Ramūnas Gutkovas
4
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Fix Committed
Low
Abdulaziz Ghuloum

Bug Description

Could you export threaded variants of match from (match) library: match+ and trace-match+

Revision history for this message
leppie (leppie) wrote :

This bug is related to: https://bugs.launchpad.net/ikarus/+bug/188607

Perhaps we can find out what it does! :)

Revision history for this message
Ramūnas Gutkovas (ramunasg) wrote :

Oh, sorry for the duplication. I am quite new to launchpad, and don't know how to get around :)

match+ is for passing multiple values, to do some paralell accumulation, e.g.:

(define expr '(1 2 (3) (5 (6)) 4))
(define x '()) ;; x must be bound

(match+ (x) expr
   ((,(a*) ...) (values a* a*)) ; the first arg passed to values whould be bound to x, second whould be normally returned just like in match
   (,a (values a a)))

whould return reconstructed list twice (multiple values):

(1 2 (3) (5 (6)) 4)
(1 2 (3) (5 (6)) 4)

hope that helps, I am not very good at explaining how things work :)

Revision history for this message
Ramūnas Gutkovas (ramunasg) wrote :

Also this can be extended to any number of values:

(match+ (x y z ...) expr clauses ...)

Revision history for this message
leppie (leppie) wrote :

I just had a look.

From what I can see there is a problem matching ",()" .

Revision history for this message
Ramūnas Gutkovas (ramunasg) wrote :

Can you elaborate, I did not understand what you mean?

Revision history for this message
leppie (leppie) wrote :

Sorry that was more of a note to Aziz.

I did try some simple examples, and as long at they do not make use of the ",()" construct the "+" derivatives seem to work correctly.

Revision history for this message
leppie (leppie) wrote :

I think I found the bug :) Andmap returns #f on empty list, which should be #t.

The correct code (round line 290):

(define (andmap f ls)
  (cond
    ((null? ls) #t) ; was #f here
    ((null? (cdr ls)) (f (car ls)))
    (else (and (f (car ls)) (andmap f (cdr ls))))))

Can you apply the change and verify? (I only tried the collect-leaves sample).

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote : Re: [Bug 301612] Re: Could you export from (match) library match+ and trace-match+

On Nov 25, 2008, at 3:18 AM, leppie wrote:

> I think I found the bug :) Andmap returns #f on empty list, which
> should be #t.

That's correct. My fault. Thanks!
Any other issues with match+ and trace-match+?

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Exported and fixed in revision 1692. Thanks for explaining match+! :-)

Changed in ikarus:
assignee: nobody → aghuloum
importance: Undecided → Low
status: New → Fix Committed
Revision history for this message
Ramūnas Gutkovas (ramunasg) wrote :

Thank you too both :)

Changed in ikarus:
milestone: none → 0.0.4
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.