Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Array slicing
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===2004: [[SuperCollider]]=== The programming language [[SuperCollider]] implements some concepts from [[J (programming language)|J]]/[[APL (programming language)|APL]]. Slicing looks as follows: <syntaxhighlight lang="sc"> a = [3, 1, 5, 7] // assign an array to the variable a a[0..1] // return the first two elements of a a[..1] // return the first two elements of a: the zero can be omitted a[2..] // return the element 3 till last one a[[0, 3]] // return the first and the fourth element of a a[[0, 3]] = [100, 200] // replace the first and the fourth element of a a[2..] = [100, 200] // replace the two last elements of a // assign a multidimensional array to the variable a a = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]; a.slice(2, 3); // take a slice with coordinates 2 and 3 (returns 13) a.slice(nil, 3); // take an orthogonal slice (returns [3, 8, 13, 18]) </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)