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.

Definitions

C compare
F fcompare, fcompares

compare (verb)

Compare character data.

Syntax:

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

where:

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

fcompare (verb)

Compare two text files.

Syntax:

opt fcompare files

where:

 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

Example:

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

fcompares (verb)

as fcompare but ignoring different line separators