[advanced programming] A function that implements a Corialization of a function.

implement a curry function as follows:
first call: console.log (curry ("l")) / / cool
second call: console.log (curry () ("l")) / / coool
third call: console.log (curry () () ("l")) / / cooool
fourth call: console.log (curry () ("l")) / / coooool
.


const curry = i => {
  let tmp = 'coo'
  const inner = i => {
    if (i) {
      return tmp + i
    } else {
      tmp += 'o'
      return inner
    }
  }
  return inner(i)
}

clipboard.png

if I can help you, please upvote, thank you ~


const demo = () = > {

let data = 'coo'

const push = (... rest) = > {
if (rest.length) {
return data+rest [0]
}
data=data+'o'
return push
}

return push
}

I don't know if the phone can run or match the meaning of the question.
pay attention to the square brackets, the phone is not half-width.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7ae735-29127.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7ae735-29127.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?