All Questions
Tagged with functional-programming lambda
14 questions
3
votes
1
answer
115
views
In Java, replace for loop with condition with lambdas [closed]
I want to replace a for loop with a break/return condition inside with a lambda.
I think I have a good replacement, but I want ...
2
votes
1
answer
83
views
Lazy evaluation vs strict one applied to fib
I have this OCaml problem:
Recall the polymorphic type lazy seen in class, the function delay which transforms a ...
2
votes
1
answer
101
views
Meta Collatz Sequence
Context
Chapter 6 of Learn You A Haskell contains a function called chain, which outputs the Collatz sequence of a given input.
(In short, it takes a natural number....
2
votes
1
answer
320
views
FizzBuzz with Lambda Expressions in Java
I wanted to create a FizzBuzz in Java that is supposed to be open for extension.
So the initial problem is the good old, if divisible by 3 print fizz, if divisible by 5 print buzz, if divisible by ...
1
vote
1
answer
324
views
Control class for an entity
For a Student object in the package entity, I have a control.studentpackage with classes ...
3
votes
1
answer
113
views
Numerical streams example
I am reading "Java 8 In Action" (by Raoul-Gabriel Urma, Mario Fusco and Alan Mycroft), section 5.6.3, pages 116 and 117. The code that is presented handles calculating so-called "Pythagorean Triples". ...
11
votes
1
answer
8k
views
Creating a pipeline operator in Java
I wrote the following as more of an experiment than anything else, but I thought it would be fun to share and maybe get some feedback!
Motivation: I started looking at some functional languages and ...
3
votes
1
answer
496
views
Church Numerals
Here is exercise 2.6 from SICP:
Exercise 2.6: In case representing pairs as procedures wasn’t
mind-boggling enough, consider that, in a language that can manipulate
procedures, we can get by ...
4
votes
1
answer
5k
views
Lambda to obtain a new merged object
The requirement is to iterate over a list of Foos, and when 2 Foos have the same id merge ...
2
votes
1
answer
3k
views
Routing Java objects using conditional consumers
As per a previous question here and answers I got, I used it to get a new implementation. I found that I have to make two implementations match once "to ignore other consumers after matching once" and ...
13
votes
2
answers
738
views
Printing removed items using lambdas and streams
I'm struggling to make my lambdas readable.
I've seen various approaches. Below are three different examples that all do the same thing.
Forgive the example: I suspect there are better actual ...
18
votes
3
answers
27k
views
Effective use of multiple streams
I am experimenting with streams and lambdas in Java 8. This is my first serious foray using functional programming concepts; I'd like a critique on this code.
This code finds the Cartesian product of ...
7
votes
1
answer
816
views
Elixir pipes and anonymous functions
I recently got started with Elixir. I'm used to F#'s pipes, and Seq.map and LINQ's .Select statements. Things are different in ...
3
votes
2
answers
499
views
Removing hackery from pair of radix functions
I like the radix function and found a really neat way to compute its inverse in Python with a lambda and reduce() (so I really feel like I'm learning my cool ...