Advertisement
emacstheviking

File slicing

Oct 25th, 2020
1,812
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
J 0.58 KB | None | 0 0
  1. NB. blocks: given a filename, answers a list of code block start
  2. NB. and stop lines. MUTATIONS: body, lines
  3. NB. pairs = I.>cblk each LF chopstring 1!:1<'smallfile.md'
  4. NB.
  5. blocks =: monad define           NB. 3 : 0
  6. body  =: 1!:1<y                  NB. body is raw file, global scope
  7. lines =: LF chopstring body      NB. lines now scanned, global scope
  8. pairs =. I.>cblk each lines      NB. consecutive start/stops, could be uneven
  9. bump  =. 2|#pairs                NB. bump is 1 for odd pairs allowing us to
  10. (bump+#pairs){.!.(#lines) pairs  NB. fill with the max line ensuring even pairs
  11. )
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement