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.

Arguments:

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

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

Refinements:

/case - Uses case-sensitive comparison

/skip - Treat the series as records of fixed size

size [integer!]

See also:

intersect   union   exclude   unique  

Description

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
"BAEF"

Date differences produce a time in hours:

probe difference 1-Jan-2002/0:00 1-Feb-2002/0:00
-744:00
probe difference 1-Jan-2003/10:30 now
-59449:55:14

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
-31
probe subtract 1-Jan-2003/10:30 now
-2477

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 > REBOL.com - WIP Wiki Feedback Admin