Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delete repeated entries in array
#5
You can use this to combine it into one function.

Function GetUniqueArrayElements
Code:
Copy      Help
function `v
int uniqueElement
sel v.vt
,case VT_I4|VT_ARRAY
,,ARRAY(int)& a=v.parray
,,uniqueElement = GetUniqueArrayElements_Int(a)
,case VT_BSTR|VT_ARRAY
,,ARRAY(str) s=v.parray
,,uniqueElement = GetUniqueArrayElements_Str(s)
,case else end ERR_BADARG
ret uniqueElement

Macro GetUniqueArrayElements Test
Code:
Copy      Help
out
ARRAY(int) a

a[] = 1
a[] = 2
a[] = 2
a[] = 3
a[] = 3
a[] = 3
a[] = 4
a[] = 5
a[] = 5

ARRAY(str) b = "red[]red[]blue[]blue[]green[]yellow[]yellow"

_i = GetUniqueArrayElements(a)
out "[]"
out F"Number of unique integer elements = {_i}"
out "[]----------[]"
_i = GetUniqueArrayElements(b)
out "[]"
out F"Number of unique str elements = {_i}"
Basicallly it's just a function wrapper only. Underneath of it you still have to define 2 separate functions for dealing with int array and str array.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)