[Swift-user] last element array indexing?
Allan Espinosa
aespinosa at cs.uchicago.edu
Sun Mar 21 17:21:38 CDT 2010
Hi,
How can I refer to the last element of the array? my external mapper
doesn't know beforehand how many elements it will give the array.
Other languages index this with negative integers.
Sample script:
type File;
File arr[] <ext;exec="arbitrary_mapper.rb">
File out <"foo.txt">;
foo = some_app(arr[-1]) /* doesn't work in swift */
arbitrary_mapper.rb
!/usr/bin/env ruby
(0..rand(20)).each do |i|
puts "[#{i}] rand#{i}.txt"
end
I can always workaround this by having another helper function that
dumps a the size of the array to a file then get it via readData().
I'm just wondering if size-of-array queres or relative element
indexing is in the plans of implementation.
thanks,
-Allan
--
Allan M. Espinosa <http://amespinosa.wordpress.com>
PhD student, Computer Science
University of Chicago <http://people.cs.uchicago.edu/~aespinosa>
More information about the Swift-user
mailing list