You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.
#!r6rs
(import (vicare)
(vicare checks)
(vicare system $fx)
(vicare system $strings))
(define ($string-reverse! str start past)
(do ((i ($fxsub1 past) ($fxsub1 i))
(j start ($fxadd1 j)))
(($fx<= i j)
str)
(let ((ci ($string-ref str i)))
($string-set! str i ($string-ref str j))
($string-set! str j ci))))
(check
(let ((S (string-copy "ciao")))
($string-reverse! S 0 4)
S)
=> "oaic")
the crash does not occur if we change some unsafe core primitive application with the corresponding safe core primitive. For example, changing $fx<= to fx<=? avoids the error.
Notice that the following code with vectors works fine:
(internal-body
(define ($vector-reverse! str start past)
(do ((i ($fxsub1 past) ($fxsub1 i))
(j start ($fxadd1 j)))
(($fx<= i j)
str)
(let ((ci ($vector-ref str i)))
($vector-set! str i ($vector-ref str j))
($vector-set! str j ci))))
(check
(let ((S (vector-copy '#(c i a o))))
($vector-reverse! S 0 4)
S)
=> '#(o a i c)))
The text was updated successfully, but these errors were encountered:
The following program crashes at run-time:
the crash does not occur if we change some unsafe core primitive application with the corresponding safe core primitive. For example, changing
$fx<=
tofx<=?
avoids the error.Notice that the following code with vectors works fine:
The text was updated successfully, but these errors were encountered: