Script Library: 1217 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Archive version of: duplicates.r ... version: 1 ... clecorre 3-Mar-2016

Amendment note: new script || Publicly available? Yes

REBOL [
    	File: %duplicates.r
    	Date: 03-03-2016
    	Title: "Duplicates"
    	Purpose: {Get duplicated values in a serie}
    	]

duplicates: func [param [block!] /sole /local output][
		output: make block! []
		loop length? param [
			if found? find (next param) param/1 [append output param/1] 
			param: next param
		]
		either sole [unique output][output]
	]

probe duplicates [1 1 2 3 4 4 4 5 6 7 7 8 9 9 9 9 10]
probe duplicates/sole [1 1 2 3 4 4 4 5 6 7 7 8 9 9 9 9 10]

; The output is:
;[1 4 4 7 9 9 9]
;[1 4 7 9]