Re: Associative array

new topic     » goto parent     » topic index » view thread      » older message » newer message
menno said...

Hum I wasn't , but forgot to change the PEU syntax into Euphoria syntax . That why I had to implement a insert() function .

Ah, your implementation of insert() does not work the same as RDS Eu 4.
(I assume the 2.5 compatible version you gave works the same as PEU)
I ran this on Eu 4:

?insert({1,2,4},{3},3) 
global function Minsert(sequence org, sequence what, integer where)  
if where then   
return org[1..where]&{what}&org[where+1..length(org)]  
else  
return {what}&org[where+1..length(org)]  
end if  
end function  
?Minsert({1,2,4},{3},3) 
if getc(0) then end if 

which gave me

{ 
  1, 
  2, 
  {3}, 
  4 
} 
{ 
  1, 
  2, 
  4, 
  {3} 
} 

FWIW, I think this is compatible with Eu 4:

global function insert(sequence target, object what, integer index) 
  return target[1..index-1] & {what} & target[index..length(target)] 
end function 

Regards, Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu