Friday, October 21, 2011

USL 3.7.8

I have added a lot of different features in 3.7.8 thanks to suggestions. I have added list slicing from Python, variable indices, variable ranges, list indices, list ranges, sub-strings, and so forth.
I have also changed the way methods execute their code. Methods may now return a list object instead of just variables, strings, and numeric values. Any variables or lists created within the method are implicitly removed after leaving the method.

Here is an example of list slicing:
list list_a
list list_b

list_a = ("abc","bcd","cde","def")

list_b = list_a[0..3]       # list_b contains all elements of list_a
list_b = list_a[3..0]       # list_b contains all elements of list_a, reversed
Here is an example of iterating a sub-string:
@string "Hello, World!"

# loop a substring
for c in @string[0..12]
       say ${c}
endfor

# reversed
for c in @string[12..0]
       say ${c}
endfor
Here is an example of retrieving a sub-string:
@string = "Hello, World!"

@sub_str = @string[0..12]
@reversed = @string[12..0]
Here is an example of the new methods:
method get_even_numbers
       list even_numbers

       for x in (0..15)
              if (${x}%2) == 0
                     even_numbers += ${x}
              endif
       endfor

       return even_numbers
end

list numbers
numbers = get_even_numbers

To download 3.7.8, you can visit any of the following links:
sourceforge
freecode

1 comment: