KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
It is by now a well known theorem of the lambda calculus that any function taking two or more arguments can be written through currying as a chain of functions taking one argument: # Pseudo-code for currying f(x,y) -> f_curried(x)(y) This has proven to be extremely powerful not just in studying the behavior of functions but in practical use (Haskell, etc.). Functions returning values, however, seem to not be discussed. Programmers typically deal with their inability to return more than one value from a function by returning some meta-object (lists in R, structures in C++, etc.). It has always struck me as a bit of a kludge, but a useful one. For instance: # R code for "faking" multiple return values uselessFunc <- function(dat) { model1 <- lm( y ~ x , data=dat ) return( list( coef=coef(model1), form=formula(model1) ) ) } Questions Does the lambda calculus have anything to say about a multiplicity of return values? If so, do any surprising conclusions result? Similarly, do any languages allow true multiple return values?
Tags (comma-separated)
Save Edits
Cancel