#Haskell question: Is there a function for "reapply this function to a starting value N times"? e.g. `doTimes (*2) 3 1` would return `8` ((*2) $ (*2) $ (*2) $ 1). I know I could chain take and iterate and then do a Data.List.last, but that has crumby performance for very large values of N.
isnt this just:
doTimes f n x = foldl’ (\acc _ -> f acc) x [1..n]
Please Login to reply.
nostr:nprofile1qy2hwumn8ghj7un9d3shjtnddaehgu3wwp6kyqpqxtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzs9d84s8 Aye, that works, it just feels like there'd be a built-in for this.
its folds all the way down