SendValue
SendValue[tx, value]
Sends value through the channel sender tx.
- Returns
Unit[].
OpenChannel[rx, tx];
SendValue[tx, "hello"];
ReceiveValue[rx]; (* => "hello" *)
Set
Set[target, key, value]
Returns a new object or list with the specified modification. The original target is unchanged.
- For an
Object:keyis anAtom; returns a new object with the propertykeyset tovalue(adding or updating). - For a
List:keyis a 1‑based index; returns a new list with the element at that position replaced byvalue.
Get[Set[Object[A, { { #a, 1 } }], #a, 2], #a]; (* => 2 *)
Set[{ 1, 2, 3 }, 2, #elem]; (* => {1, #elem, 3} *)
SetEnv
SetEnv[name, value]
Sets the environment variable name to value for the current KSL process.
nameandvalueareStrings.- Returns
Unit[].
SetEnv["VarA", "isA"];
GetEnv["VarA"]; (* => "isA" *)
ShiftL
ShiftL[m, n]
Performs a bitwise left shift of m by n bits.
Uses unbounded semantics: shifting beyond the bit width yields 0.
mandnshould be non‑negative integers.- Returns a
Number.
ShiftL[2, 7]; (* => 256 *)
ShiftL[2, 256]; (* => 0 *)
ShiftR
ShiftR[m, n]
Performs a bitwise right shift of m by n bits.
Uses unbounded semantics: shifting beyond the bit width yields 0.
mandnshould be non‑negative integers.- Returns a
Number.
ShiftR[1024, 3]; (* => 128 *)
ShiftR[2, 256]; (* => 0 *)
Sin
Sin[n]
Computes the sine of an angle n given in radians.
- Returns a
Numberin the range$\left[-1, 1\right]$.
Sin[0]; (* => 0 *)
Sin[1.5707963267949]; (* => 1 *)
Sinh
Sinh[n]
Computes the hyperbolic sine of n.
- Returns a
Number.
Sinh[0]; (* => 0 *)
Sinh[1]; (* => 1.1752011936438 *)
Sinh[-1]; (* => -1.1752011936438 *)
Sleep
Sleep[n]
Pauses the current thread for n seconds. Fractional values are supported.
nshould be a non‑negativeNumber.- Returns
Unit[].
(* Pauses for 1.5 seconds *)
Sleep[1.5];
SlideBy
SlideBy[list, n]
Returns a list of sliding windows of size n over list.
Each window is a sublist of consecutive elements.
- If
listis shorter thann, returns an empty list. - Returns a
ListofLists.
SlideBy[Range[1, 1, 5], 3]; (* => {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}} *)
SlideBy[{ 1, 2 }, 3]; (* => {} *)
SplitBy
SplitBy[s, delimiter]
Splits a string s into substrings using a literal string or a regular expression delimiter.
- Returns a
ListofStrings.
SplitBy["hello,world", ","]; (* => {"hello", "world"} *)
SplitBy["a1b2c3d4e", "\d"]; (* => {"a", "b", "c", "d", "e"} *)
Sqrt
Sqrt[n]
Computes the square root of n.
- Returns a
Number. Ifnis negative, returnsnan.
Sqrt[9]; (* => 3 *)
Sqrt[2]; (* => 1.4142135623731 *)
Sqrt[-1]; (* => nan *)
Sub
Sub[a, b]
Returns the difference $a - b$.
- Returns a
Number.
Sub[10, 4]; (* => 6 *)
Sub[5, 7]; (* => -2 *)
SubString
SubString[s, start, end]
Extracts a substring from s beginning at the start and ending at the end (inclusive).
The function is Unicode‑aware.
- Returns a
String.
SubString["hello, World", 2, 5]; (* => "ello" *)
SubString["你好世界", 2, 3]; (* => "好世" *)