REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: difference

difference  set1  set2  /case  /skip  size

Returns the difference of two data sets or dates.


set1 [block! string! binary! bitset! date! typeset!] - First data set

set2 [block! string! binary! bitset! date! typeset!] - Second data set


/case - Uses case-sensitive comparison

/skip - Treat the series as records of fixed size

size [integer!]

See also:

intersect   union   exclude   unique  


Returns the elements of two series that are not present in both. Both series arguments must be of the same datatype (string, block, etc.) Newer versions of REBOL also let you use difference to compute the difference between date/times.

lunch: [ham cheese bread carrot]
dinner: [ham salad carrot rice]
probe difference lunch dinner
[cheese bread salad rice]
probe difference [1 3 2 4] [3 5 4 6]
[1 2 5 6]
string1: "CBAD"    ; A B C D scrambled
string2: "EDCF"    ; C D E F scrambled
probe difference string1 string2

Date differences produce a time in hours:

probe difference 1-Jan-2002/0:00 1-Feb-2002/0:00
probe difference 1-Jan-2003/10:30 now

This is different from when using subtract, which returns the difference in days:

probe subtract 1-Jan-2002/0:00 1-Feb-2002/0:00
probe subtract 1-Jan-2003/10:30 now

There is a limit to the time period that can be differenced between dates (determined by the internal size of the time! datatype).

Note that performing this function over very large data sets can be CPU intensive.

  TOC < Back Next > - WIP Wiki Feedback Admin