键盘快捷键

使用 跳转章节

使用 S/ 在本书内搜索

使用 ? 显示帮助页面

使用 Esc 隐藏帮助页面

KSL Wiki

Welcome to the official documentation for the KSL programming language. This site provides a comprehensive reference covering the following areas:

  • Language Specification – Detailed syntax rules and core language concepts.
  • Built-in Function Reference – Complete guide to the standard library and available built-in functions.
  • Examples and Tutorials – Practical code samples and walkthroughs to help you get started.

Creating Standalone Executables

KSL includes a utility script, bundle.sh, that packages a KSL script together with the interpreter into a single, standalone executable.

Prerequisites

The following three files must be placed in the same directory before running the script:

  1. The bundle.sh script itself.
  2. The ksl interpreter executable.
  3. The KSL script you intend to bundle.

Usage

Invoke the script as follows:

./bundle.sh <ksl_script_file> <output_executable_name>

Example

The following script, fib10.ksl, computes the 10th Fibonacci number:

Let[{ a, b, m }, { 0, 1, 0 }];
While[Less[m, 10], {
  Update[{ a, b }, { b, Add[a, b] }],
  Update[m, Add[m, 1]]
}];
Print[a];

To package this script into an executable named fib10, execute:

./bundle.sh fib10.ksl fib10

This command produces the executable file fib10. Both the original script and the bundled executable yield identical output:

> ./ksl fib10.ksl
55.0

> ./fib10
55.0