PadLeft
PadLeft[list, elem, n]
Pads list on the left by inserting n copies of elem.
- Returns a new list with
ncopies ofelemprepended to the left side oflist. - If
nis zero or negative,listis returned unchanged.
PadLeft[{ 1, 2, 3 }, #elem, 3]; (* => {#elem, #elem, #elem, 1, 2, 3} *)
PadLeft[{ 1, 2, 3 }, #elem, 0]; (* => {1, 2, 3} *)
PadRight
PadRight[list, elem, n]
Pads list on the right by inserting n copies of elem.
- Returns a new list with
ncopies ofelemappended to the right side oflist. - If
nis zero or negative,listis returned unchanged.
PadRight[{1, 2, 3}, #elem, 3]; (* => {1, 2, 3, #elem, #elem, #elem} *)
PadRight[{1, 2, 3}, #elem, 0]; (* => {1, 2, 3} *)
ParseNumber
ParseNumber[s]
Parses a string s into a number.
- Returns a
Numberif the string represents a valid numeric literal (including"nan"and"inf"). - An error is raised if the string cannot be parsed as a number.
ParseNumber["12.2e-3"]; (* => 0.0122 *)
ParseNumber["nan"]; (* => nan *)
ParseNumber["another"];
(*? Error[ksl::builtin::ParseNumber]: `another` is not a valid number string. *)
ParseNumber
ParseNumber[s]
Parses a string s into a number.
- Returns a
Numberif the string represents a valid numeric literal (including"nan"and"inf"). - An error is raised if the string cannot be parsed as a number.
ParseNumber["12.2e-3"]; (* => 0.0122 *)
ParseNumber["nan"]; (* => nan *)
ParseNumber["another"];
(*? Error[ksl::builtin::ParseNumber]: `another` is not a valid number string. *)
Plugin
Plugin[name, "lib/export"]
Declares a foreign function interface (FFI) binding to an external native library.
nameis theSymbolthat will be bound to the imported function in the current environment.- The second argument is a
Stringspecifying the library path and exported symbol name, separated by a forward slash. - Returns
Unit[].
Plugin[RaylibGetTime, "ksl_cplugin/cplugin_raylib_get_time"];
(* RaylibGetTime can now be called as a regular KSL function *)
Power
Power[b, e]
Computes b raised to the power of e ($b^e$).
- Returns a
Number.
Power[3, 4]; (* => 81 *)
Power[2, -1]; (* => 0.5 *)
Power[9, 0.5]; (* => 3 *)
Prepend
Prepend[list, element]
Returns a new list with element inserted at the beginning of list.
The original list is unchanged.
- Returns a new
List.
Prepend[{ 1, 2, 3 }, #elem]; (* => { #elem, 1, 2, 3 } *)
Let[v, { 1, 2 }];
Prepend[v, 0]; (* => { 0, 1, 2 } *)
Print[v]; (* => { 1, 2 } *)
Print[val]
Print[val, end]
Prints the string representation of val to standard output, followed by a newline (or a custom end string).
- If
endis provided, it replaces the default newline. - Returns
Unit[].
Print["Hello, World!"]; (* Prints with a trailing newline *)
Print["Progress: ", ""]; (* Prints without a trailing newline *)
Print["100%"]; (* Continues on the same line *)
Pwd
Pwd[]
Returns the current working directory as an absolute path.
- Returns a
String.
Pwd[]; (* => "/home/user" *)