def tokens(code_str, xmap_str): # lines from code_str. remove \n and attach lines = fp.go( code_str, F.curry(F.partition_by)(lambda s: s == '\n'), fp.lmap(''.join), # Ignore newlines in beginning of source code lambda xs: F.rest(xs) if '\n' in xs[0] else xs, # join ['source line', '\n\n\n'] F.curry(F.chunks)(2), fp.lmap(''.join), ) # slice_idxs from xmap_str. indexes for each lines. slice_idxs = fp.go( #TODO: change to map and pipe xmap_str.splitlines(), fp.map(fp.pipe( lambda s: s.strip(), lambda s: s.split(), fp.map(int), fp.lmap(fp.dec), # TODO: list or tuple? # Make tokens from the beginning of the line lambda xs: [0] + xs[1:] if xs else xs, )), #fp.remove(fp.is_empty) fp.lremove(fp.is_empty) ) return fp.tmapcat( fp.tsplit_with, slice_idxs, lines )


const pipe2 = (a, b) => (arg) => b(a(arg)); const pipe = (...ops) => ops.reduce(pipe2) const tup = f => argtup => f(...argtup) tap = x => {console.log(x); return x} function scroll(div, lineno, max,min) { const real_h = div.scrollHeight - div.clientHeight a = real_h / (max - min) // 913, 26 is b = -min * a div.scrollTop = a * lineno + b } [...document.querySelectorAll('.comp_table tr')].slice(1).forEach( tr => tr.addEventListener('click', (() => { const [a_mid, b_mid] = [...tr.children] .map(x => x.textContent) .slice(1,3) // idx 0 is no, 1,2 are A,B. dict would be better.. .map(pipe( s => s.split(' ~ '), arr => arr.map(Number), //tup( (b,e) => (b+e)/2 ))) tup( (b,e) => Math.trunc( (b+e)/2 ) ))) const [a_div,b_div] = [...document.querySelectorAll('.row .column')].slice(0,2); const [min, bottom_offset] = [22, 29] // FIXED! const [a_max, b_max] = [...document.querySelectorAll('.linenos')] .map(pipe( x => x.textContent, s => s.split('\n'), ns => ns[ns.length -1], Number, n => n - bottom_offset )) scroll(a_div, a_mid, a_max, min) // same view line scroll(b_div, b_mid, b_max, min) } )))


파이썬이나 js로 함슬람을 하라 이말이야