Re: R-alpha: returning a list from a function

Thomas Lumley (thomas@biostat.washington.edu)
Fri, 20 Sep 1996 16:46:24 -0700 (PDT)


Date: Fri, 20 Sep 1996 16:46:24 -0700 (PDT)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: Jim Robison-Cox <jimrc@mathfs.math.montana.edu>
Subject: Re: R-alpha: returning a list from a function
In-Reply-To: <Pine.ULT.3.91.960920161556.18269E-100000@mathfs.math.montana.edu>

On Fri, 20 Sep 1996, Jim Robison-Cox wrote:
> 
> There's a difference between S and R which may be intentional, probably is 
> good programming practice, but needs to be noted:
> 
> When returning a list of results from a function, the list format seems 
> implicit in Splus, not in R:

I don't think this wants to be changed, but here is a fix for anyone who 
needs it (put it in .First so it's only run once per session)

 ret:=return
 return:=function(...) 
 {
	temp <- list(...)
	if (is.null(temp)) 
		ret()
	else if (length(temp) == 1) 
		ret(temp[[1]])
	else ret(temp)
 }


thomas lumley
U Washington
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-