Functional Programming with Java
functionaljava.org
Functional Programming with Java
1–10 of 30 posts
Re: Functional Programming with Java
#2 final HAppend, HCons>>, HCons>>>> one = append(zero);
It's here that I miss the repurposed auto keyword of C++ to do some rudimentary type inference.Re: Functional Programming with Java
#3Taken from one of the examples : final HAppend , HCons >>, HCons >>>> one = append(zero); It's here that I miss the repurposed auto keyword of C++ to do some rudimentary type inference.
final boolean b = a.exists(new F() {
public Boolean f(final String s) {
return fromString(s).forall(isLowerCase);
}
});
It's here that I miss lambdas to make functional code at all readable.Re: Functional Programming with Java
#4Taken from one of the examples : final HAppend , HCons >>, HCons >>>> one = append(zero); It's here that I miss the repurposed auto keyword of C++ to do some rudimentary type inference.
Re: Functional Programming with Java
#5We need your support and trust!!! Dear friends, please temporarily stop your footsteps To our website Walk around A look at Maybe you'll find happiness in your sight shopping heaven and earth You'll find our price is more suitable for you. Welcome to our website ( http://www.findsoso.com / ) Thanks to the support!
( http://www.findsoso.com / ) ( http://www.findsoso.com / ) ( http://www.findsoso.com /
Re: Functional Programming with Java
#6Taken from one of the examples : final HAppend , HCons >>, HCons >>>> one = append(zero); It's here that I miss the repurposed auto keyword of C++ to do some rudimentary type inference.
Or C#'s var keyword, for that matter. Unfortunately, both will only work for local variables. I suspect this is one of the reasons there aren't any popular persistent data structure libraries around for these languages. At least the .NET/C# type system supports covariance/contravariance for functions ("delegates"). Plus, they managed to build F# on it.
For type inference, you just need a sufficiently smart compiler, although it's much more useful if your language knows about generic types.
Re: Functional Programming with Java
#7Taken from one of the examples : final HAppend , HCons >>, HCons >>>> one = append(zero); It's here that I miss the repurposed auto keyword of C++ to do some rudimentary type inference.
final boolean b = a.exists(new F () { public Boolean f(final String s) { return fromString(s).forall(isLowerCase); } }); It's here that I miss lambdas to make functional code at all readable.
val b = a.exists(str=>str.forall(_.isLowerCase))
or
val b = a.exists(x=>x.toLowerCase() == x)
There's no way I'd start using functional programming in Java if it's this clunky. Just stick with Scala.
Re: Functional Programming with Java
#8Re: Functional Programming with Java
#9Or even better than using libraries for functional programming in Java, learn and use Scala. You can mix Scala and Java code where needed.
Re: Functional Programming with Java
#10Earlier quoted context omitted.
Or C#'s var keyword, for that matter. Unfortunately, both will only work for local variables. I suspect this is one of the reasons there aren't any popular persistent data structure libraries around for these languages. At least the .NET/C# type system supports covariance/contravariance for functions ("delegates"). Plus, they managed to build F# on it.
F# doesn't in fact make use of {co|contra}variance: it only needed generics. (Although F# used to run on .NET 1.x using its own implementation of generics - Don Syme designed both .NET generics and the F# language.) For type inference, you just need a sufficiently smart compiler, although it's much more useful if your language knows about generic types.