Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Icon (programming language)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
===Strings=== In Icon, strings are lists of characters. As a list, they are generators and can thus be iterated over using the bang syntax: <syntaxhighlight lang="icon"> write(!"Hello, world!") </syntaxhighlight> Will print out each character of the string on a separate line. Substrings can be extracted from a string by using a range specification within brackets. A range specification can return a point to a single character, or a [[array slicing|slice]] of the string. Strings can be indexed from either the right or the left. Positions within a string are defined to be '''between''' the characters <sub>1</sub>A<sub>2</sub>B<sub>3</sub>C<sub>4</sub> and can be specified from the right <sub>β3</sub>A<sub>β2</sub>B<sub>β1</sub>C<sub>0</sub> For example, <syntaxhighlight lang="icon"> "Wikipedia"[1] ==> "W" "Wikipedia"[3] ==> "k" "Wikipedia"[0] ==> "a" "Wikipedia"[1:3] ==> "Wi" "Wikipedia"[-2:0] ==> "ia" "Wikipedia"[2+:3] ==> "iki" </syntaxhighlight> Where the last example shows using a length instead of an ending position The subscripting specification can be used as a [[value (computer science)#lrvalue|lvalue]] within an expression. This can be used to insert strings into another string or delete parts of a string. For example: <syntaxhighlight lang="icon"> s := "abc" s[2] := "123" s now has a value of "a123c" s := "abcdefg" s[3:5] := "ABCD" s now has a value of "abABCDefg" s := "abcdefg" s[3:5] := "" s now has a value of "abefg" </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Icon (programming language)
(section)
Add topic