nus-cs2030 / 2021-s1

28 stars 48 forks source link

Function composition #195

Open KongXinyue opened 3 years ago

KongXinyue commented 3 years ago

AF166FBD1EACFD249D9B57CB934E9F11

I'm confused because I think andThen() method has achieved the composition process while mystery=twice(twice()) instead of twice(). What does andThen() really do ??

SkyBlaise99 commented 3 years ago

mystery calls twice 2 times same as calling f.andThen(f) 2 times same as calling f 4 times

KongXinyue commented 3 years ago

So it should be f^4 instead of f^2?

SkyBlaise99 commented 3 years ago

Yup. Iirc u get 65536=2^16=x^2 4 times where x=2