This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
module.exports = diff | |
const MATCH = 0 | |
const REMOVE = 1 | |
const INSERT = 2 | |
const REPLACE = 3 | |
function diff (fromArr, toArr, diffKey) { | |
const len1 = fromArr.length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define call/cc call-with-current-continuation) | |
;;;;;;;;;;;;;; | |
(call/cc (lambda (cont) 2)) ; 2, cont do nothing | |
(call/cc (lambda (cont) (cont 2))) ; 2, cont do nothing | |
(* 3 (call/cc (lambda (cont) | |
(+ 1 2)))) ; 9, cont is not used |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
/** | |
* note: substitute costs 2 | |
* | |
* if either string is empty => length of the other | |
* if the last chars of both match => | |
* recursively call edit without adding distance | |
* if not => | |
* Math.min of three ways |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
function promisify (fakeAjax){ | |
let content = null | |
let func = null | |
return function (url) { | |
fakeAjax(url, (err, data) => { | |
if (err) { | |
throw Error('unhandled error') | |
} |
NewerOlder