Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Saving work done in coffee console
getRamda = ->
script = document.createElement('script')
script.type = 'text/javascript'
script.src = 'https://rawgit.com/ramda/ramda/master/dist/ramda.js'
document.head.appendChild(script)
letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
charToNumber = (char) ->
idx = R.indexOf char, letters
++idx
numberToChar = (number) ->
letters[--number]
convertStr = R.compose R.map(charToNumber), R.split("")
convertNumbers = R.compose R.join(""), R.map(numberToChar)
incrementN = (idx, arr) ->
val = arr[idx] + 1
if val > 26
arr[idx] = 1
incrementN(--idx, arr)
else
arr[idx] = val
arr
increment = (arr) ->
idx = arr.length - 1
incrementN idx, arr
incrementStr = R.compose convertNumbers, increment, convertStr
haha = (str) ->
incStr = incrementStr str
console.log incStr
window.x = setTimeout haha.bind(null, incStr), 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.