Last active
August 29, 2015 14:00
-
-
Save alokito/b13b5fb8c1fdfdb80fe4 to your computer and use it in GitHub Desktop.
Analysis of stack overflow post http://stackoverflow.com/questions/4262241/how-to-return-a-function-in-scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class wrapper { | |
val fib: Stream[Int] = 1 #:: 1 #:: (fib zip fib.tail map Function.tupled(_+_)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.Function.; | |
import scala.ScalaObject; | |
import scala.Serializable; | |
import scala.collection.GenIterable; | |
import scala.collection.TraversableLike; | |
import scala.collection.immutable.Stream; | |
import scala.collection.immutable.Stream.; | |
import scala.collection.immutable.Stream.ConsWrapper; | |
import scala.reflect.ScalaSignature; | |
import scala.runtime.AbstractFunction0; | |
import scala.runtime.AbstractFunction2.mcIII.sp; | |
import scala.runtime.BoxesRunTime; | |
@ScalaSignature(bytes="\006\00152A!\001\002\001\013\t9qO]1qa\026\024(\"A\002\002\017q*W\016\035;z}\r\0011c\001\001\007\035A\021q\001D\007\002\021)\021\021BC\001\005Y\006twMC\001\f\003\021Q\027M^1\n\0055A!AB(cU\026\034G\017\005\002\020%5\t\001CC\001\022\003\025\0318-\0317b\023\t\031\002CA\006TG\006d\027m\0242kK\016$\b\"B\013\001\t\0031\022A\002\037j]&$h\bF\001\030!\tA\002!D\001\003\021\035Q\002A1A\005\002m\t1AZ5c+\005a\002cA\017&Q9\021ad\t\b\003?\tj\021\001\t\006\003C\021\ta\001\020:p_Rt\024\"A\t\n\005\021\002\022a\0029bG.\fw-Z\005\003M\035\022aa\025;sK\006l'B\001\023\021!\ty\021&\003\002+!\t\031\021J\034;\t\r1\002\001\025!\003\035\003\0211\027N\031\021") | |
public class wrapper | |
implements ScalaObject | |
{ | |
private final Stream<Object> fib; | |
public Stream<Object> fib(){ return this.fib; } | |
public wrapper() { | |
int i = 1; | |
this.fib = Stream..MODULE$.consWrapper(new AbstractFunction0() { | |
public static final long serialVersionUID = 0L; | |
public final Stream<Object> apply() { | |
int i = 1; | |
return Stream..MODULE$.consWrapper(new AbstractFunction0() { | |
public static final long serialVersionUID = 0L; | |
public final Stream<Object> apply() { | |
return (Stream)( | |
(Stream)wrapper..anonfun.1.this.wrapper$$anonfun$$$outer().fib() | |
.zip((GenIterable)wrapper..anonfun.1.this.wrapper$$anonfun$$$outer().fib().tail(), Stream..MODULE$.canBuildFrom()) | |
).map(Function..MODULE$.tupled(new AbstractFunction2.mcIII.sp() { | |
public static final long serialVersionUID = 0L; | |
public final int apply(int paramAnonymous3Int1, int paramAnonymous3Int2) { | |
return apply$mcIII$sp(paramAnonymous3Int1, paramAnonymous3Int2); | |
} | |
public int apply$mcIII$sp(int v1, int v2) { | |
return v1 + v2; | |
} | |
}), Stream..MODULE$.canBuildFrom()); | |
} | |
}).$hash$colon$colon(BoxesRunTime.boxToInteger(i)); } | |
public wrapper wrapper$$anonfun$$$outer() { return wrapper.this; } | |
}).$hash$colon$colon(BoxesRunTime.boxToInteger(i)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment