Похожие чаты

Const sum = (...args) => args.reduce((a, b) => a +

b, 0);

How I can create curry function to execute this sum function with rest params?

I would like to execute like

curry(sum)(1)()(2) => 3

8 ответов

10 просмотров
decoder- Автор вопроса

I have tried but sum function doesn't have length so it's returning function only

decoder- Автор вопроса
decoder
I have tried but sum function doesn't have length ...

trying but not working I am doing something wrong here

You can't, a curried function has to know its length

decoder
ohh okay I was figuring from last one hour :D

Currying is taking a function like (a, b, c) -> and converting it to a -> b -> c -> So by definition it can't work if it doesn't know length

decoder- Автор вопроса
MUTHU・KUMAR 「メーカー」 🔺
Currying is taking a function like (a, b, c) -> an...

Yeah right I though it might possible but I was stuck with unknown length of function

Похожие вопросы

Обсуждают сегодня

Карта сайта