键盘快捷键

使用 跳转章节

使用 S/ 在本书内搜索

使用 ? 显示帮助页面

使用 Esc 隐藏帮助页面

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: key is an Atom; returns a new object with the property key set to value (adding or updating).
  • For a List: key is a 1‑based index; returns a new list with the element at that position replaced by value.
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.

  • name and value are Strings.
  • 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.

  • m and n should 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.

  • m and n should 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 Number in 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.

  • n should be a non‑negative Number.
  • 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 list is shorter than n, returns an empty list.
  • Returns a List of Lists.
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 List of Strings.
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. If n is negative, returns nan.
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];      (* => "好世" *)