All Questions
18 questions
1
vote
3
answers
846
views
Use the Stream API to create List from HashMap with elements arranged in specific order
I have a HashMap<String, List<Appliance>> where the field name::String from the object Appliance is used as a key, and each value in the HashMap is a list of Appliance objects. Each list, ...
8
votes
5
answers
6k
views
How to count vowels in Java through functional programming?
I need to count the number of vowels in a list of words in Functional Java.
If I have this list:
List<String> l = Arrays.asList("hello", "world", "test");
My idea was to "delete" the vowels ...
1
vote
3
answers
250
views
How we I achieve add(4)(10)(20)(3)(1).total using Java Function?
I am learning usage of,
java.util.function.Function
I wrote a code which uses java Function to add 4 to itself,
the code is as follows,
public class Test01 {
public static void main(String[] ...
4
votes
3
answers
2k
views
Filtering on Java 8 List
I have a list of type List in functional java using List type provided by fj.data.List
import fj.data.List
List<Long> managedCustomers
I am trying to filter it using the following:
...
0
votes
1
answer
331
views
Different Optional/Option semantics in Java [closed]
I am trying to understand reasons behind different Option/Optional semantics in probably 3 most used implementations in Java ecosystem: Java 8, Functional Java and Guava.
Considering following three ...
3
votes
1
answer
1k
views
Using Fugue/FunctionalJava to Move Away From Null and Throws?
Okay, so I'm a long time OO developer trying to get into this "newfound" world of functional programming - at the very least, as it pertains to this, I'm trying to code like null and throw don't exist ...
2
votes
0
answers
191
views
How do Java 8 lambdas differ from anonymous classes as objects (under the hood)? [duplicate]
EDIT:
how is this question different from Java8 Lambdas vs Anonymous classes:
The answers provided in the previous question are regarding of how they work in a higher level. I already understand the ...
1
vote
3
answers
782
views
How can I use functional programming to do string manipulation?
I'm writing a function where I'm essentially doing the same thing over and over. I have the function listed below
public String buildGarmentsString(List<Garment> garments)
{
StringBuilder ...
0
votes
2
answers
435
views
Scope management - Stateful IO Monad?
I am playing with functional programming and in particular with Functional Java. I have implemented with success my version of the IO Monad and I am writing IO actions for my core. It is basically ...
0
votes
2
answers
392
views
How to construct a FunctionalJava TreeMap?
I'm just starting to use the FunctionalJava library and wanted to make use of the immutable TreeMap. However I can't figure out how to create an empty one to start with when using a user defined class ...
0
votes
1
answer
109
views
Fold on Option, instead of `if maybeT.isNone()`
This is a similar question to Why doesn't Option have a fold method?, but for functional-java.
I want to perform some side-effect if an option is None. Is there something I can use other than if ...
2
votes
2
answers
226
views
Name for pattern in which actions happen upon completion of a future event / Java class
I have a class currently called Promise that works as follows:
It holds a future value
It can always accept a subsequent action to take that uses the future value as the parameter
When the value is ...
6
votes
3
answers
4k
views
Mapping a FunctionalJava Option<Type> with Hibernate
I have a hibernate-mapped Java object, JKL, which is full of a bunch of normal hibernate-mappable fields (like strings and integers).
I'm added a new embedded field to it (which lives in the same ...
1
vote
1
answer
530
views
functional java - transform by calling a member function
I'm coming at some functional java from a ruby point of view
in ruby you can do something like this
mapped_array = [1,2,3].map(&:to_s)
which evaluates out to transforming (map) the array by ...
13
votes
3
answers
5k
views
Is there a good comparison between Functional Java and Guava?
I'd like to use either Functional Java or Guava (or less likely Scala) in a course I'll be teaching. Although there are lots of functional languages that run on the JVM I'd like to stick to something ...