Skip to content

Instantly share code, notes, and snippets.

@haywoood
Created May 3, 2015 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haywoood/30d2edc793d7042a0cf1 to your computer and use it in GitHub Desktop.
Save haywoood/30d2edc793d7042a0cf1 to your computer and use it in GitHub Desktop.
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