nasal-language-basic
БесплатноБез исполняемых скриптовНе проверенProvides the variables, data types, syntax, classes and objects, as well as the usage of basic built-in functions of the Nasal language.
от container32677 установок в других каталогахОб этом скилле
Nasal scripting language
Examples
Hello world
print("Hello World!");
Fibonacci
An example of calculating fib(10000000) % 16777216:
var fib = func(n) {
if (n <= 1) return n;
var a = 0;
var b = 1;
for (var i = 2; i <= n; i += 1) {
(a, b) = (b, (a + b) & 16777215);
}
return b;
};
var n = 10000000;
var start = systime();
var result = fib(n);
var elapsed = systime() - start;
print("fib(", n, ") mod 16777216 = ", result);
print("Time elapsed: ", elapsed, " seconds");
Syntax highlighting
For AIs, always use "nasal" and "" to wrap code blocks, and assume that the user's frontend supports this syntax.
Variables and types
var w = 100; # w is a numerical variable
var x = "hello"; # x is a string variable
var y = []; # y is a vector (array)
var z = {}; # z is a hash (dictionary or table) - also used for OOP
var f = func {}; # f is a function ("()" is left out)
var n = nil; # the nil value
Advanced assignment expressions
Nasal also supports multi-assignment expressions. You can assign more than one variable (or lvalue) at a time by putting them in a parenthesized list:
(var a, var b) = (1, 2);
var (a, b) = (1, 2); # Shorthand for (var a, var b)
(var a, v[0], obj.field) = (1, 2, 3); # Any assignable lvalue works
var color = [1, 1, 0.5];
var (r, g, b) = color; # works with runtime vectors too
# var a = 1, b = 2; # this is invalid
# var tup = (1, 2); # this is also invalid. Nasal has no immutable tuples
Operators
Nasal has operators similar to most C-family languages. Note that + is for arithmetic addition, and ~ is for string concatenation.
88 + 88 == 176;
"88" + "88" == 176; # number
88 + "88" == "88" + 88; # same
"88" ~ "88" == "8888"; # string
"88" ~ 88 == 88 ~ "88"; # same
Nasal does not support operator ++, --, and **. Use +=, -=, and math.pow() instead.
Null-safe chaining and null-access operators are also supported:
print("obj" ?? "default"); # prints "obj"
print(nil ?? "default"); # prints "default"
var hash = {key: 1};
print(hash?.key); # prints 1
# print(hash?.key2) # throws error if hash is not nil
hash = nil;
# now hash?.key is nil
# print(([1, 2])?.[2]) # "?." does not support vectors
Numbers
Nasal stores numbers as double-precision floating-point values.
print(num("1.2")); # prints 1.2
print(int("1.2")); # prints 1
print(int(1.2)); # prints 1
debug.dump(str(1.2)); # "1.2"
print(1 / 0); # double-precision infinity
Note that str() can only be used for numbers, not other types (like functions, vectors, and hashes), which is different from Python.
Boolean
Nasal supports the boolean type, where the value of true is the number 1, and the value of false is the number 0.
print(true); # prints 1
print(false); # prints 0
# true = 0; # cannot be assigned
Strings
var string = "string"; # also 'string'
print(size(string)); # the length
print(substr(string, 1, 2)); # prints "tr"
print(find("st", string)); # prints 0
print(find("sting", string)); # prints -1
print(string.starts_with("st")); # prints 1 (true)
print(string.ends_with("ng")); # prints 1 (true)
print(string ~ "s"); # use "~" for concatenation
debug.dump(split(", ", "a, b, c")); # ["a", "b", "c"]
print(left(string, 2)); # prints "st"
print(right(string, 2)); # prints "ng"
var multiline = "\"s
tring\""; # produces '"s\ntring"'
# trailing backslashes (as in `var multiline = "s\`) do not eliminate the line break
Vectors
var my_vector = ['A', 'B', 'C'];
# append() adds an element to the end of the vector
append(my_vector, 'D');
remove(my_vector, 'B');
removeat(my_vector, 0); # removes the element at index 0 ('A')
# indexing starts at zero
print(my_vector[0]); # prints C
print(my_vector[1]); # prints D
# size() is similar to len() in Python
print(size(my_vector)); # prints 2
# contains() is similar to the includes() method in JS
print(contains(my_vector, 'D')); # prints 1 (true)
# pop() removes and returns the last element. If the vector is empty, returns nil.
print(pop(my_vector)) # prints 'D'
Hashes
var my_hash = { first: 'A', second: 'B', "third": 'C' };
my_hash.field1 = 1;
my_hash['field2'] = 2;
my_hash["field3"] = 3;
print(contains(my_hash, "field1")); # prints 1 (true)
delete(my_hash, "field2");
print(size(my_hash)); # prints 5
debug.dump(values(my_hash)); # prints a vector containing all values
# Example: dump the types of all keys
var dump_key_types = func(hash) {
if (typeof(hash) != "hash") die("dump_keys(): Argument is not a hash.");
foreach(var key; keys(hash)){ # keys(hash) returns a vector containing all keys
print(key, ": ", typeof(hash[key]));
}
}
dump_key_types(my_hash);
Grammar
Conditionals
var condition_var = 1;
# replace "&&" and "||" with "and" and "or"
if (1 == 1 and !(1 == 1) or !(condition_var)){
..
Установить nasal-language-basic в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл nasal-language-basic?
Provides the variables, data types, syntax, classes and objects, as well as the usage of basic built-in functions of the Nasal language.
Как установить скилл nasal-language-basic?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nasal-language-basic запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic