I am new to Icon, so this is most certainly my fault, but I am not
understanding where to go from here. I have a rather contorted matching
function that takes a variable number of arguments. It's not necessary
to go into that. Here is what I would like to accomplish:
if (a is null OR a == data[1])
AND (b is null OR b == data[2])
AND (c is null OR c == data[3])
then return index
So, if the user supplies a, it's matched, otherwise, it skips that
match. So on for b and c. Here is my real Icon code:
every idx := startAt to *spec do {
if (/loopName | loopName == spec[idx][1]) &
(/segName | segName == spec[idx][2]) &
( /segMod | segMod == spec[idx][3]) then return idx
}
When my function runs, I get this:
Run-time error 103
File edispec.icn; Line 14
string expected
offending value: &null
Traceback:
main()
testX096() from line 24 in edispec.icn
position_of(list_485 =
[list_1(3),list_2(3),list_3(3),...,list_482(3),list_483(3),list_484(3)],1
,"CLM",&null,&null) from line 7 in edispec.icn
{&null == ""} from line 14 in edispec.icn
Now, I decided to break this down and figure out exactly where the error
is happening and in the process I now have:
every idx := startAt to *spec do {
if /loopName | loopName == spec[idx][1] then
if /segName | segName == spec[idx][2] then
if /segMod | segMod == spec[idx][3] then
return idx
}
The above code works just as I would expect it to. With this code about
30 unit tests pass just fine, the other code, 30 unit tests fails.
So, my question is what is wrong with my first if statement?
Thank you,
Jeremy


|