upscheme/scheme-tests/ast/rpasses-out.scm

1702 lines
100 KiB
Scheme
Raw Normal View History

'(r-expressions (<- Sys.time (lambda ()
(let () (r-block (r-call structure (r-call
.Internal (r-call
Sys.time))
(*named* class (r-call
c "POSIXt" "POSIXct")))))))
(<- Sys.timezone (lambda ()
(let ()
(r-block (r-call as.vector (r-call
Sys.getenv
"TZ"))))))
(<- as.POSIXlt (lambda (x tz)
(let ((x ())
(tzone ())
(fromchar ())
(tz ()))
(r-block (when (missing tz)
(<- tz ""))
(<- fromchar (lambda (x)
(let ((res ())
(f ())
(j ())
(xx ()))
(r-block (<-
xx (r-call r-index x 1))
(if (r-call is.na xx) (r-block (<- j 1)
(while (&& (r-call is.na xx)
(r-call <= (<- j (r-call + j 1))
(r-call length x)))
(<- xx (r-call r-index x j)))
(if (r-call is.na xx)
(<- f "%Y-%m-%d"))))
(if (|\|\|| (r-call is.na xx) (r-call ! (r-call is.na (r-call strptime xx
(<- f "%Y-%m-%d %H:%M:%OS"))))
(r-call ! (r-call is.na (r-call strptime xx
(<- f "%Y/%m/%d %H:%M:%OS"))))
(r-call ! (r-call is.na (r-call strptime xx
(<- f "%Y-%m-%d %H:%M"))))
(r-call ! (r-call is.na (r-call strptime xx
(<- f "%Y/%m/%d %H:%M"))))
(r-call ! (r-call is.na (r-call strptime xx
(<- f "%Y-%m-%d"))))
(r-call ! (r-call is.na (r-call strptime xx
(<- f "%Y/%m/%d")))))
(r-block (<- res (r-call strptime x f))
(if (r-call nchar tz) (r-block (<- res (r-call attr<- res "tzone"
tz))
tz))
(return res)))
(r-call stop "character string is not in a standard unambiguous format")))))
(if (r-call inherits x "POSIXlt")
(return x))
(if (r-call inherits x "Date")
(return (r-call .Internal (r-call
Date2POSIXlt x))))
(<- tzone (r-call attr x "tzone"))
(if (|\|\|| (r-call inherits x "date")
(r-call inherits x "dates"))
(<- x (r-call as.POSIXct x)))
(if (r-call is.character x)
(return (r-call fromchar (r-call
unclass x))))
(if (r-call is.factor x)
(return (r-call fromchar (r-call
as.character x))))
(if (&& (r-call is.logical x)
(r-call all (r-call is.na
x)))
(<- x (r-call
as.POSIXct.default x)))
(if (r-call ! (r-call inherits x
"POSIXct"))
(r-call stop (r-call gettextf
"do not know how to convert '%s' to class \"POSIXlt\""
(r-call deparse (substitute x)))))
(if (&& (missing tz)
(r-call ! (r-call is.null
tzone)))
(<- tz (r-call r-index tzone
1)))
(r-call .Internal (r-call
as.POSIXlt x
tz))))))
(<- as.POSIXct (lambda (x tz)
(let ((tz ()))
(r-block (when (missing tz)
(<- tz ""))
(r-call UseMethod "as.POSIXct")))))
(<- as.POSIXct.Date (lambda (x ...)
(let ()
(r-block (r-call structure (r-call *
(r-call unclass x) 86400)
(*named* class (r-call
c "POSIXt" "POSIXct")))))))
(<- as.POSIXct.date (lambda (x ...)
(let ((x ()))
(r-block (if (r-call inherits x "date")
(r-block (<- x (r-call
* (r-call - x 3653) 86400))
(return (r-call
structure x (*named* class (r-call c "POSIXt" "POSIXct")))))
(r-call stop (r-call
gettextf "'%s' is not a \"date\" object"
(r-call deparse (substitute x)))))))))
(<- as.POSIXct.dates (lambda (x ...)
(let ((x ())
(z ()))
(r-block (if (r-call inherits x "dates")
(r-block (<- z (r-call
attr x "origin"))
(<- x (r-call
* (r-call as.numeric x) 86400))
(if (&& (r-call
== (r-call length z) 3)
(r-call is.numeric z))
(<- x (r-call + x
(r-call as.numeric (r-call ISOdate (r-call r-index z 3)
(r-call r-index z 1)
(r-call r-index z 2) 0)))))
(return (r-call
structure x (*named* class (r-call c "POSIXt" "POSIXct")))))
(r-call stop (r-call
gettextf "'%s' is not a \"dates\" object"
(r-call deparse (substitute x)))))))))
(<- as.POSIXct.POSIXlt (lambda (x tz)
(let ((tzone ())
(tz ()))
(r-block (when (missing tz)
(<- tz ""))
(<- tzone (r-call attr x
"tzone"))
(if (&& (missing tz)
(r-call ! (r-call
is.null tzone)))
(<- tz (r-call
r-index tzone
1)))
(r-call structure (r-call
.Internal (r-call as.POSIXct x tz))
(*named* class (r-call
c "POSIXt" "POSIXct"))
(*named* tzone tz))))))
(<- as.POSIXct.default (lambda (x tz)
(let ((tz ()))
(r-block (when (missing tz)
(<- tz ""))
(if (r-call inherits x "POSIXct")
(return x))
(if (|\|\|| (r-call
is.character
x)
(r-call
is.factor x))
(return (r-call
as.POSIXct
(r-call
as.POSIXlt
x)
tz)))
(if (&& (r-call
is.logical x)
(r-call all (r-call
is.na x)))
(return (r-call
structure (r-call
as.numeric x)
(*named*
class (r-call
c "POSIXt" "POSIXct")))))
(r-call stop (r-call
gettextf "do not know how to convert '%s' to class \"POSIXlt\""
(r-call
deparse (substitute x))))))))
(<- as.numeric.POSIXlt (lambda (x)
(let ()
(r-block (r-call as.POSIXct x)))))
(<- format.POSIXlt (lambda (x format usetz ...)
(let ((np ())
(secs ())
(times ())
(usetz ())
(format ()))
(r-block (when (missing format)
(<- format ""))
(when (missing usetz)
(<- usetz *r-false*))
(if (r-call ! (r-call
inherits x "POSIXlt"))
(r-call stop "wrong class"))
(if (r-call == format "")
(r-block (<- times (r-call
unlist (r-call r-index (r-call unclass x)
(r-call : 1 3))))
(<- secs (r-call
r-aref x (index-in-strlist sec (r-call attr x #0="names"))))
(<- secs (r-call
r-index secs (r-call ! (r-call is.na secs))))
(<- np (r-call
getOption "digits.secs"))
(if (r-call
is.null np)
(<- np 0)
(<- np (r-call
min 6 np)))
(if (r-call >=
np 1)
(r-block (for
i (r-call - (r-call : 1 np) 1)
(if (r-call all (r-call < (r-call abs (r-call - secs
(r-call round secs i)))
9.9999999999999995e-07))
(r-block (<- np i) (break))))))
(<- format (if
(r-call all (r-call == (r-call r-index times
(r-call ! (r-call is.na times)))
0))
"%Y-%m-%d" (if (r-call == np 0) "%Y-%m-%d %H:%M:%S"
(r-call paste "%Y-%m-%d %H:%M:%OS" np
(*named* sep "")))))))
(r-call .Internal (r-call
format.POSIXlt x format usetz))))))
(<- strftime format.POSIXlt)
(<- strptime (lambda (x format tz)
(let ((tz ()))
(r-block (when (missing tz)
(<- tz ""))
(r-call .Internal (r-call strptime
(r-call as.character x) format tz))))))
(<- format.POSIXct (lambda (x format tz usetz ...)
(let ((tzone ())
(usetz ())
(tz ())
(format ()))
(r-block (when (missing format)
(<- format ""))
(when (missing tz)
(<- tz ""))
(when (missing usetz)
(<- usetz *r-false*))
(if (r-call ! (r-call
inherits x "POSIXct"))
(r-call stop "wrong class"))
(if (&& (missing tz)
(r-call ! (r-call
is.null (<- tzone (r-call attr x "tzone")))))
(<- tz tzone))
(r-call structure (r-call
format.POSIXlt (r-call as.POSIXlt x tz) format usetz r-dotdotdot)
(*named* names (r-call
names x)))))))
(<- print.POSIXct (lambda (x ...)
(let ()
(r-block (r-call print (r-call format
x (*named* usetz *r-true*) r-dotdotdot)
r-dotdotdot)
(r-call invisible x)))))
(<- print.POSIXlt (lambda (x ...)
(let ()
(r-block (r-call print (r-call format
x (*named* usetz *r-true*))
r-dotdotdot)
(r-call invisible x)))))
(<- summary.POSIXct (lambda (object digits ...)
(let ((x ())
(digits ()))
(r-block (when (missing digits)
(<- digits 15))
(<- x (r-call r-index (r-call
summary.default (r-call unclass object)
(*named* digits digits) r-dotdotdot)
(r-call : 1 6)))
(r-block (ref= %r:1 (r-call
oldClass object))
(<- x (r-call
class<- x
%r:1))
%r:1)
(r-block (ref= %r:2 (r-call
attr object "tzone"))
(<- x (r-call
attr<- x "tzone"
%r:2))
%r:2)
x))))
(<- summary.POSIXlt (lambda (object digits ...)
(let ((digits ()))
(r-block (when (missing digits)
(<- digits 15))
(r-call summary (r-call
as.POSIXct
object)
(*named* digits
digits)
r-dotdotdot)))))
(<- "+.POSIXt" (lambda (e1 e2)
(let ((e2 ())
(e1 ())
(coerceTimeUnit ()))
(r-block (<- coerceTimeUnit (lambda (x)
(let ()
(r-block (switch (r-call attr x "units")
(*named* secs x) (*named* mins (r-call * 60 x))
(*named* hours (r-call * (r-call * 60 60) x))
(*named* days (r-call * (r-call * (r-call * 60 60) 24) x))
(*named* weeks (r-call * (r-call * (r-call * (r-call * 60 60)
24)
7)
x)))))))
(if (r-call == (r-call nargs) 1)
(return e1))
(if (&& (r-call inherits e1 "POSIXt")
(r-call inherits e2 "POSIXt"))
(r-call stop "binary + is not defined for \"POSIXt\" objects"))
(if (r-call inherits e1 "POSIXlt")
(<- e1 (r-call as.POSIXct e1)))
(if (r-call inherits e2 "POSIXlt")
(<- e2 (r-call as.POSIXct e2)))
(if (r-call inherits e1 "difftime")
(<- e1 (r-call coerceTimeUnit
e1)))
(if (r-call inherits e2 "difftime")
(<- e2 (r-call coerceTimeUnit
e2)))
(r-call structure (r-call + (r-call
unclass e1)
(r-call unclass e2))
(*named* class (r-call c
"POSIXt" "POSIXct"))
(*named* tzone (r-call
check_tzones e1 e2)))))))
(<- "-.POSIXt" (lambda (e1 e2)
(let ((e2 ())
(coerceTimeUnit ()))
(r-block (<- coerceTimeUnit (lambda (x)
(let ()
(r-block (switch (r-call attr x "units")
(*named* secs x) (*named* mins (r-call * 60 x))
(*named* hours (r-call * (r-call * 60 60) x))
(*named* days (r-call * (r-call * (r-call * 60 60) 24) x))
(*named* weeks (r-call * (r-call * (r-call * (r-call * 60 60)
24)
7)
x)))))))
(if (r-call ! (r-call inherits e1
"POSIXt"))
(r-call stop "Can only subtract from POSIXt objects"))
(if (r-call == (r-call nargs) 1)
(r-call stop "unary - is not defined for \"POSIXt\" objects"))
(if (r-call inherits e2 "POSIXt")
(return (r-call difftime e1
e2)))
(if (r-call inherits e2 "difftime")
(<- e2 (r-call unclass (r-call
coerceTimeUnit e2))))
(if (r-call ! (r-call is.null (r-call
attr e2 "class")))
(r-call stop "can only subtract numbers from POSIXt objects"))
(r-call structure (r-call - (r-call
unclass (r-call as.POSIXct e1))
e2)
(*named* class (r-call c
"POSIXt" "POSIXct")))))))
(<- Ops.POSIXt (lambda (e1 e2)
(let ((e2 ())
(e1 ())
(boolean ()))
(r-block (if (r-call == (r-call nargs) 1)
(r-call stop "unary" .Generic
" not defined for \"POSIXt\" objects"))
(<- boolean (switch .Generic (*named*
< *r-missing*)
(*named* >
*r-missing*)
(*named* ==
*r-missing*)
(*named* !=
*r-missing*)
(*named* <=
*r-missing*)
(*named* >=
*r-true*)
*r-false*))
(if (r-call ! boolean)
(r-call stop .Generic
" not defined for \"POSIXt\" objects"))
(if (|\|\|| (r-call inherits e1
"POSIXlt")
(r-call is.character
e1))
(<- e1 (r-call as.POSIXct e1)))
(if (|\|\|| (r-call inherits e2
"POSIXlt")
(r-call is.character
e1))
(<- e2 (r-call as.POSIXct e2)))
(r-call check_tzones e1 e2)
(r-call NextMethod .Generic)))))
(<- Math.POSIXt (lambda (x ...)
(let () (r-block (r-call stop .Generic
" not defined for POSIXt objects")))))
(<- check_tzones (lambda (...)
(let ((tzs ()))
(r-block (<- tzs (r-call unique (r-call
sapply (r-call list r-dotdotdot) (lambda (x)
(let ((y ()))
(r-block (<- y (r-call attr x "tzone"))
(if (r-call is.null y) "" y)))))))
(<- tzs (r-call r-index tzs
(r-call != tzs
"")))
(if (r-call > (r-call length
tzs)
1)
(r-call warning "'tzone' attributes are inconsistent"))
(if (r-call length tzs)
(r-call r-index tzs 1)
())))))
(<- Summary.POSIXct (lambda (... na.rm)
(let ((val ())
(tz ())
(args ())
(ok ()))
(r-block (<- ok (switch .Generic (*named*
max *r-missing*)
(*named* min
*r-missing*)
(*named*
range
*r-true*)
*r-false*))
(if (r-call ! ok)
(r-call stop .Generic
" not defined for \"POSIXct\" objects"))
(<- args (r-call list
r-dotdotdot))
(<- tz (r-call do.call "check_tzones"
args))
(<- val (r-call NextMethod
.Generic))
(r-block (ref= %r:3 (r-call
oldClass (r-call r-aref args 1)))
(<- val (r-call
class<- val %r:3))
%r:3)
(r-block (<- val (r-call
attr<- val "tzone" tz))
tz)
val))))
(<- Summary.POSIXlt (lambda (... na.rm)
(let ((val ())
(tz ())
(args ())
(ok ()))
(r-block (<- ok (switch .Generic (*named*
max *r-missing*)
(*named* min
*r-missing*)
(*named*
range
*r-true*)
*r-false*))
(if (r-call ! ok)
(r-call stop .Generic
" not defined for \"POSIXlt\" objects"))
(<- args (r-call list
r-dotdotdot))
(<- tz (r-call do.call "check_tzones"
args))
(<- args (r-call lapply args
as.POSIXct))
(<- val (r-call do.call
.Generic (r-call
c args (*named* na.rm na.rm))))
(r-call as.POSIXlt (r-call
structure val (*named* class (r-call c "POSIXt" "POSIXct"))
(*named* tzone tz)))))))
(<- "[.POSIXct" (lambda (x ... drop)
(let ((val ())
(x ())
(cl ())
(drop ()))
(r-block (when (missing drop)
(<- drop *r-true*))
(<- cl (r-call oldClass x))
(r-block (<- x (r-call class<-
x ()))
())
(<- val (r-call NextMethod "["))
(r-block (<- val (r-call class<-
val cl))
cl)
(r-block (ref= %r:4 (r-call attr
x "tzone"))
(<- val (r-call attr<-
val "tzone" %r:4))
%r:4)
val))))
(<- "[[.POSIXct" (lambda (x ... drop)
(let ((val ())
(x ())
(cl ())
(drop ()))
(r-block (when (missing drop)
(<- drop *r-true*))
(<- cl (r-call oldClass x))
(r-block (<- x (r-call class<-
x ()))
())
(<- val (r-call NextMethod "[["))
(r-block (<- val (r-call
class<- val
cl))
cl)
(r-block (ref= %r:5 (r-call
attr x "tzone"))
(<- val (r-call attr<-
val "tzone" %r:5))
%r:5)
val))))
(<- "[<-.POSIXct" (lambda (x ... value)
(let ((x ())
(tz ())
(cl ())
(value ()))
(r-block (if (r-call ! (r-call
as.logical (r-call
length value)))
(return x))
(<- value (r-call as.POSIXct
value))
(<- cl (r-call oldClass x))
(<- tz (r-call attr x "tzone"))
(r-block (ref= %r:6 (r-block
(<- value (r-call class<- value
()))
()))
(<- x (r-call class<-
x %r:6))
%r:6)
(<- x (r-call NextMethod
.Generic))
(r-block (<- x (r-call class<-
x cl))
cl)
(r-block (<- x (r-call attr<-
x "tzone" tz))
tz)
x))))
(<- as.character.POSIXt (lambda (x ...)
(let ()
(r-block (r-call format x
r-dotdotdot)))))
(<- as.data.frame.POSIXct as.data.frame.vector)
(<- is.na.POSIXlt (lambda (x)
(let ()
(r-block (r-call is.na (r-call
as.POSIXct x))))))
(<- c.POSIXct (lambda (... recursive)
(let ((recursive ()))
(r-block (when (missing recursive)
(<- recursive *r-false*))
(r-call structure (r-call c (r-call
unlist (r-call lapply (r-call list r-dotdotdot) unclass)))
(*named* class (r-call c
"POSIXt" "POSIXct")))))))
(<- c.POSIXlt (lambda (... recursive)
(let ((recursive ()))
(r-block (when (missing recursive)
(<- recursive *r-false*))
(r-call as.POSIXlt (r-call do.call
"c" (r-call lapply (r-call list r-dotdotdot) as.POSIXct)))))))
(<- all.equal.POSIXct (lambda (target current ... scale)
(let ((scale ()))
(r-block (when (missing scale)
(<- scale 1))
(r-call check_tzones
target current)
(r-call NextMethod "all.equal")))))
(<- ISOdatetime (lambda (year month day hour min sec tz)
(let ((x ())
(tz ()))
(r-block (when (missing tz)
(<- tz ""))
(<- x (r-call paste year month
day hour min sec
(*named* sep "-")))
(r-call as.POSIXct (r-call
strptime x
"%Y-%m-%d-%H-%M-%OS"
(*named* tz
tz))
(*named* tz tz))))))
(<- ISOdate (lambda (year month day hour min sec tz)
(let ((tz ())
(sec ())
(min ())
(hour ()))
(r-block (when (missing hour)
(<- hour 12))
(when (missing min)
(<- min 0))
(when (missing sec)
(<- sec 0))
(when (missing tz)
(<- tz "GMT"))
(r-call ISOdatetime year month day
hour min sec tz)))))
(<- as.matrix.POSIXlt (lambda (x ...)
(let ()
(r-block (r-call as.matrix (r-call
as.data.frame (r-call unclass x))
r-dotdotdot)))))
(<- mean.POSIXct (lambda (x ...)
(let ()
(r-block (r-call structure (r-call mean
(r-call unclass x) r-dotdotdot)
(*named* class (r-call
c "POSIXt" "POSIXct"))
(*named* tzone (r-call
attr x "tzone")))))))
(<- mean.POSIXlt (lambda (x ...)
(let ()
(r-block (r-call as.POSIXlt (r-call mean
(r-call as.POSIXct x) r-dotdotdot))))))
(<- difftime (lambda (time1 time2 tz units)
(let ((zz ())
(z ())
(time2 ())
(time1 ())
(units ())
(tz ()))
(r-block (when (missing tz)
(<- tz ""))
(when (missing units)
(<- units (r-call c "auto" "secs"
"mins" "hours"
"days" "weeks")))
(<- time1 (r-call as.POSIXct time1
(*named* tz tz)))
(<- time2 (r-call as.POSIXct time2
(*named* tz tz)))
(<- z (r-call - (r-call unclass
time1)
(r-call unclass time2)))
(<- units (r-call match.arg units))
(if (r-call == units "auto")
(r-block (if (r-call all (r-call
is.na z))
(<- units "secs")
(r-block (<- zz (r-call
min (r-call abs z) (*named* na.rm *r-true*)))
(if (|\|\|| (r-call is.na zz) (r-call < zz 60))
(<- units "secs") (if (r-call < zz 3600)
(<- units "mins")
(if (r-call < zz 86400)
(<- units "hours")
(<- units "days"))))))))
(switch units (*named* secs (r-call
structure z (*named* units "secs")
(*named* class "difftime")))
(*named* mins (r-call
structure (r-call
/ z 60)
(*named*
units "mins")
(*named*
class "difftime")))
(*named* hours (r-call
structure
(r-call /
z 3600)
(*named*
units "hours")
(*named*
class "difftime")))
(*named* days (r-call
structure (r-call
/ z 86400)
(*named*
units "days")
(*named*
class "difftime")))
(*named* weeks (r-call
structure
(r-call /
z (r-call * 7 86400))