+ 2

How do I get run this composition[solved]

It works ... but not for reduce https://code.sololearn.com/ca8a25a157A2

20th May 2021, 2:59 PM
Oma Falk
Oma Falk - avatar
11 Respostas
+ 3
this link may help you to understand how to use reduce() for compositing: https://mathieularose.com/function-composition-in-JUMP_LINK__&&__python__&&__JUMP_LINK
20th May 2021, 3:15 PM
visph
visph - avatar
+ 2
visph thats actually what I wanted. But why does my way not work? I reduce a value with a function and get a value again. Val,func The link does the same with func,func
20th May 2021, 3:25 PM
Oma Falk
Oma Falk - avatar
+ 2
actually you pass to callme() two functions, while it expect one arg and one function: you are skipping the compose() function step of the link (wich takes two functions as arguments) and you should add callme calls somewhere else ^^
20th May 2021, 3:37 PM
visph
visph - avatar
+ 2
Yeah....I added the initializer now it works
20th May 2021, 3:44 PM
Oma Falk
Oma Falk - avatar
+ 2
:D I was trying that first of all, but got error saying that reduce doesn't expect 'initializer' argument ^^
20th May 2021, 3:46 PM
visph
visph - avatar
+ 2
sorry I don't understand your last reply? In mine, I was implicitly saying 'named' argument... but finally you successed by passing initializer as unnamed argument, wich I have not tried ;P
20th May 2021, 3:51 PM
visph
visph - avatar
+ 1
Yeah forgot to save
20th May 2021, 3:48 PM
Oma Falk
Oma Falk - avatar
+ 1
I forgot to save the working version.
20th May 2021, 3:52 PM
Oma Falk
Oma Falk - avatar
+ 1
Oh I see now... no need of your old callme function ^^
20th May 2021, 3:53 PM
visph
visph - avatar
+ 1
Oh...tell me how?
20th May 2021, 4:48 PM
Oma Falk
Oma Falk - avatar
+ 1
I mean the one wich was expecting arg and function as argument ^^ now your actual callme function is like the compose2 one returned by compose function in the link I had first provided ;P
20th May 2021, 4:51 PM
visph
visph - avatar