20 lines
426 B
Text
20 lines
426 B
Text
a = ["Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty", "Charlie", "Bush", "Boz", "Zag"]
|
|
|
|
test[a, "Washington"]
|
|
test[a, "Ronald"]
|
|
|
|
println[]
|
|
println["Extra credit:"]
|
|
[mosts, count] = mostCommon[a]
|
|
for m = mosts
|
|
println["$m\toccurs $count times, last at index " + a.lastIndexOf[m]]
|
|
|
|
test[a, str] :=
|
|
{
|
|
print["$str:\t"]
|
|
i = a.indexOf[str]
|
|
if i == -1
|
|
println["does not exist in list"]
|
|
else
|
|
println[i]
|
|
}
|