Skip to content
Snippets Groups Projects
Commit 3b26bb08 authored by Michael Aaron Murphy's avatar Michael Aaron Murphy
Browse files

Update README

parent b7d3224a
No related branches found
No related tags found
No related merge requests found
...@@ -17,9 +17,9 @@ core functionality is complete. Features below: ...@@ -17,9 +17,9 @@ core functionality is complete. Features below:
- [x] Array Expressions (**[]**) - [x] Array Expressions (**[]**)
- [x] Array-based Command Substitution (**@[]**) - [x] Array-based Command Substitution (**@[]**)
- [x] String-based Command Substitution (**$()**) - [x] String-based Command Substitution (**$()**)
- [ ] String-to-Array Methods (**@split(var, ' ')**) - [ ] Array Methods (**@split(var, ' ')**)
- [ ] Array-to-String Methods (**$join(array, ', ')**) - [ ] String Methods (**$join(array, ', ')**)
- [ ] Array Splicing - [x] Array Splicing
- [ ] Maps - [ ] Maps
- [x] For Loops - [x] For Loops
- [ ] Foreach Loops - [ ] Foreach Loops
...@@ -191,16 +191,38 @@ echo @braced_array ...@@ -191,16 +191,38 @@ echo @braced_array
echo @{braced_array} echo @{braced_array}
``` ```
Arrays may also be spliced when an index or index range is supplied: Arrays may also be sliced when an index or index range is supplied:
#### Slice by Index
Slicing by an index will take a string from an array:
```ion ```ion
# Slicing not yet implemented let array = [ 1 2 3 ]
echo @array[0] echo @array[0]
echo @array[0..3] echo @array[1]
echo @array[2]
echo [ 1 2 3 ][0]
echo [ 1 2 3 ][1]
echo [ 1 2 3 ][2]
echo @[echo 1 2 3][0]
echo @[echo 1 2 3][1]
echo @[echo 1 2 3][2]
```
#### Slice by Range
let i = 1 Slicing by range will take a subsection of an array as a new array:
echo @array[$i]
echo @array[$i+1] ```ion
let array = [ 1 2 3 4 5 ]
echo @array[0..1]
echo @array[0...1]
echo @array[..3]
echo @array[3..]
echo @array[..]
``` ```
### Commands ### Commands
......
...@@ -16,7 +16,6 @@ const DQUOTE: u8 = 4; ...@@ -16,7 +16,6 @@ const DQUOTE: u8 = 4;
#[derive(Debug, PartialEq, Copy, Clone)] #[derive(Debug, PartialEq, Copy, Clone)]
pub enum Index { pub enum Index {
// TODO: Ranged and ID
All, All,
None, None,
ID(usize), ID(usize),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment