Binary search: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 3,386: | Line 3,386: | ||
where=-where-1 |
where=-where-1 |
||
if where<len(A()) then |
if where<len(A()) then |
||
Print "Not found, we can insert it at index: ";where |
Print "Not found, we can insert it at index: ";where |
||
Dim A(len(A())+1) ' redim |
Dim A(len(A())+1) ' redim |
||
stock A(where) keep len(A())-where-1, A(where+1) 'move items up |
stock A(where) keep len(A())-where-1, A(where+1) 'move items up |
||
A(where)=i ' insert value |
A(where)=i ' insert value |
||
Else |
Else |
||
Print "Not found, we can append to array at index: ";where |
Print "Not found, we can append to array at index: ";where |
||
Dim A(len(A())+1) ' redim |
Dim A(len(A())+1) ' redim |
||
A(where)=i ' insert value |
A(where)=i ' insert value |
||
Line 3,401: | Line 3,401: | ||
</lang> |
</lang> |
||
=={{header|M4}}== |
=={{header|M4}}== |
||
<lang M4>define(`notfound',`-1')dnl |
<lang M4>define(`notfound',`-1')dnl |