unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* [bug #30070] multiple returns from map
@ 2010-06-07 18:23 Szavai Gyula
  2011-07-15 10:45 ` Stefan Israelsson Tampe
  0 siblings, 1 reply; 7+ messages in thread
From: Szavai Gyula @ 2010-06-07 18:23 UTC (permalink / raw)
  To: Szavai Gyula, bug-guile


URL:
  <http://savannah.gnu.org/bugs/?30070>

                 Summary: multiple returns from map
                 Project: Guile
            Submitted by: szgyg
            Submitted on: Mon 07 Jun 2010 06:23:03 PM GMT
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

; R6RS 11.9:
; "If multiple returns occur from map, the values returned by
; earlier returns are not mutated."

(display "\nGuile's broken map\n")

(define k #f)
(define result #f)
(define results '())
(set! result (map (lambda (x)
                    (if x x (call/cc (lambda (c)
                                       (set! k c)
                                       1))))
                  '(#t #f)))
(set! results (cons result results))
(write results)
(newline)
(if (< (cadr result) 5)
    (k (+ 1 (cadr result))))
(newline)

;;;;;;;;;;;

(display "Correct map implementation\n") ; regarding call/cc.

(define (map f xs)                  ; it isn't tail-recursive
  (if (null? xs) '() (cons (f (car xs)) (map f (cdr xs)))))

(define k #f)
(define result #f)
(define results '())
(set! result (map (lambda (x)
                    (if x x (call/cc (lambda (c)
                                       (set! k c)
                                       1))))
                  '(#t #f)))
(set! results (cons result results))
(write results)
(newline)
(if (< (cadr result) 5)
    (k (+ 1 (cadr result))))
(newline)





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?30070>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




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

end of thread, other threads:[~2011-08-17 21:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07 18:23 [bug #30070] multiple returns from map Szavai Gyula
2011-07-15 10:45 ` Stefan Israelsson Tampe
2011-08-12 21:03   ` Andy Wingo
2011-08-13 15:56     ` Stefan Israelsson Tampe
2011-08-14 20:03       ` Andy Wingo
2011-08-14 20:52         ` Stefan Israelsson Tampe
2011-08-17 21:29     ` Andy Wingo

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).