arraylast( in theory

James Cook JC at JamesCook.biz
Sat Feb 23 08:51:23 PST 2008


I don't know if it's a bug or not, but I would expect that arrylast( 
would respond much as a regular array( if there is no more than a 
single element in an array.

Take the string "abcd"

array( "abcd",1,".") returns "abcd"
array( "abcd",2,".") returns ""
arrayfirst( "abcd",".") returns "abcd"
arraylast( "abcd",".") returns "abcd"

I would expect arraylast( to return "" although I can see all the 
arguments for otherwise.

But consider:
extract( "abcd",".",1)  returns "abcd"
extract( "abcd",".",2)  returns ""
"abcd" [1,"."]  returns "abcd"
"abcd" [".",-1]  returns ""


So the theoretically based question is, if there is one or no element 
in an array, does the array actually have a last element, or is the 
last element empty?

Array sizes can vary a lot from nothing to many elements. Finding the 
first is easy, but grabbing the last only if there are multiple 
elements seems to require something like:
?(arraysize("abcd",".") > 1,array("abcd",arraysize("abcd","."),"."),"")

The appeal of arraylast( is being to reliably get the last element 
without having to calculate where it is or if it even exists.


-- 
James Cook
JC at JamesCook.biz
720-252-7042

Proficiencies
http://JamesCook.biz

Founder of HindSight Ltd.
http://HSLtd.us

Custom Panorama Applications
Specializing in Panorama Enterprise for the Web


More information about the Qna mailing list