Splice: Difference between revisions

From The K Language Wiki
Content added Content deleted
(Created page with "{{primitive|?[x;(s;e);z]|in=K5,K6}} '''Splice''' is a special form of the <code>?</code> verb which takes 3 arguments. * <code>x</code> is the array to be modified. * <code>(s;e)</code> is a two element array indicating start index and end index * <code>z</code> is the replacement array. In ngn/k, splice removes the portion of the array <code>x</code> from <code>s</code> to <code>e</code>, exclusive of <code>e</code> and inserts <code>z</code> in that place. <pre> ?[...")
 
("Better category ordering, add redirects to categories, fix pseudo-adverb categories")
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{primitive|?[x;(s;e);z]|in=K5,K6}}
{{primitive|?[x;(s;e);z]|in=K5,K6}}


'''Splice''' is a special form of the <code>?</code> verb which takes 3 arguments.
'''splice''' is a special form of the <code>?</code> verb which takes 3 arguments.


* <code>x</code> is the array to be modified.
* <code>x</code> is the array to be modified.
Line 13: Line 13:
?["abcd";3 4;"x"]
?["abcd";3 4;"x"]
"abcx"</pre>
"abcx"</pre>

[[Category:Verbs]]
[[Category:Special forms]]
[[Category:Primitives]]

Latest revision as of 06:42, 9 July 2022

Splice
?[x;(s;e);z]
Supported in K5,K6

splice is a special form of the ? verb which takes 3 arguments.

  • x is the array to be modified.
  • (s;e) is a two element array indicating start index and end index
  • z is the replacement array.

In ngn/k, splice removes the portion of the array x from s to e, exclusive of e and inserts z in that place.

 ?["abcd";3 3;"x"]
"abcxd"
 ?["abcd";3 4;"x"]
"abcx"