Standard Library/compare

From J Wiki
Jump to navigation Jump to search
Overview | android | break | colib | compare | coutil | dates | debug | dir | dll | files | jade | jal | stdlib | strings | sysenv | text | unxlib

This script defines comparison utilities and is included in the J standard library. Definitions are loaded into the jcompare locale with cover functions in z.


C compare
F fcompare, fcompares

compare (verb)

Compare character data.


text1 compare text2

Arguments may be character strings or character matrices with trailing blanks ignored.

Result shows lines not matched, in form:

n [l] text


  n = 0=left argument, 1=right argument
 [l] = line number
 text = text on line

fcompare (verb)

Compare two text files.


opt fcompare files


 opt is optional suffix
 files is 2 file names or prefixes, given
 either as character string cut on blanks
 or as 2-element boxed list


fcompare '~mywork/myutil.ijs ~/jbak/mywork/myutil.ijs'
'/myutil.ijs' fcompare jpath '~mywork';'/jbak/mywork'

fcompares (verb)

as fcompare but ignoring different line separators