[GAP Forum] Need Help with first gap code
    sam johnson 
    liveat1892 at gmail.com
       
    Thu Nov 14 21:26:26 GMT 2013
    
    
  
Hey guys I'm new to this forum and i need help with my code. My code should
basically return the position of the maximum element in the list which is
quite easy the problem that it keeps giving me the following message and
I'm sure the logic of the code is correct.
Code:
whereismax := function(L)
    local x, maxpos;
    maxpos := 0;
    for x in [1..Size(L)-1]do
         if  L[x] > L[maxpos] then
            maxpos :=  x;
         fi;
    od;
    return maxpos;
end;
Error message:
Error, no method found! For debugging hints type ?Recovery from
NoMethodFound
Error, no 1st choice method found for `[]' on 2 arguments called from
Size( L ) called from
<function "whereismax">( <arguments> )
 called from read-eval loop at line 40 of *stdin*
    
    
More information about the Forum
mailing list