1. Eu 2.5: new sequence functions
- Posted by Tommy Carlier <tommy.carlier at pandora.be> Jan 13, 2004
- 397 views
Wouldn't we all like some new (fast as hell) sequence functions? (length) (append) (prepend) s = insert(s, i, o) -- insert object o in sequence s at position i s = remove(s, i) -- remove element at position i from sequence s s = replace(s, i, o) -- replace element at position i in sequence s with object o Wouldn't these 3 little (not so complex) functions add a lot of power to Euphoria and its sequence system? Sure, you can already do them right now like this: insert(s, i, o) = s[1..i-1] & o & s[i..length(s)] remove(s, i) = s[1..i-1] & s[i+1..length(s)] replace(s, i, o) = s[1..i-1] & o & s[i+1..length(s)] But it might be too slow for applications that need pure power. And the above only works if 1 < i < length(s), so you'd have to check for boundaries. ______________ tommy online: http://users.pandora.be/tommycarlier