I want to translate something from F# to Arrow: F...
# arrow
b
I want to translate something from F# to Arrow: F#
Copy code
[1..10]
|> List.map (add 2)
|> List.map (mult 3)
My attempts: #1
Copy code
(1..10)
    .pipe { it.map { add(2) } }
    .pipe { it.map { mult(3) } }
#2
Copy code
(1..10)
    .map { add(2) }
    .map { mult(3) }
What am I missing? I'd expect a list like:
[9,12,15,18,21,24,27,30,33,36]
, but instead get a
List<(Int) -> Int>
b
do you have something like
val add(x) = { it + x }
or the like?
b
Yes, sorry:
Copy code
val add = { x: Int, y: Int -> x + y }
b
Try
.map(add(2))
{ add(2) }
is a function that returns the partially applied
add
function, although it surprises me that Kotlin automatically curried it for you
to explain a little further,
{ add(2) }
is equivalent to
{ it -> add(2) }
so it just maps the integer to the partially-applied function
s
(0..10).map { it + 2 }.map { it * 3 }
or
(0..10).toList()…
There is no need for Arrow in this case
Copy code
(1..10)
    .map(add(2))
    .map(mult(3))
is what you want here
You’re ignoring your input param there, and simply return the curried function.
Same is happening in #1
Kotlin is not very friendly for curry’ing IMO
b
Thanks a lot, both of you! Yeah I am preparing the currying / partial application part of my presentation and I already got confused multiple times myself hahaha