Pad: Difference between revisions

From The K Language Wiki
Content added Content deleted
(add pad page)
 
("Better category ordering, add redirects to categories, fix pseudo-adverb categories")
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{primitive|x$y}}
{{primitive|x$s}}


'''Pad''' pads a string with spaces on one side to a specific length, based on an integer <code>x</code>.
'''pad''' pads a string with spaces on one side to a specific length, based on an integer <code>x</code>.


Positive integers pad on the right, and negative integers pad on the left.
Positive integers pad on the right, and negative integers pad on the left.
Line 17: Line 17:
"cd "))
"cd "))
</pre>
</pre>

[[Category:Verbs]]
[[Category:Operator verbs]]
[[Category:Primitives]]

Latest revision as of 06:42, 9 July 2022

Pad
x$s

pad pads a string with spaces on one side to a specific length, based on an integer x.

Positive integers pad on the right, and negative integers pad on the left.

Padding is fully atomic, and special cased to treat strings as atoms.

  10$"abc"
"abc       "

  (3;4;(5;6))$("xy";"za";("bc";"cd"))
("xy "
 "za  "
 ("bc   "
  "cd    "))