mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-26 21:08:45 +08:00
add new functions
This commit is contained in:
+18
-4
@@ -1,11 +1,17 @@
|
||||
# this file includes functions:
|
||||
# append
|
||||
# subvec
|
||||
# this file includes basic operation functions:
|
||||
# append
|
||||
# subvec
|
||||
# int
|
||||
# num
|
||||
# made by github user: ValKmjolnir
|
||||
|
||||
# append is used to add a new var into an array/vector
|
||||
var append=func(vector,elements...)
|
||||
{
|
||||
return __call_special_inline_function(vector,elements);
|
||||
};
|
||||
|
||||
# subvec is used to get a new array from an exist array
|
||||
var subvec=func(vector,begin,length)
|
||||
{
|
||||
var new_vector=[];
|
||||
@@ -16,7 +22,15 @@ var subvec=func(vector,begin,length)
|
||||
return new_vector;
|
||||
};
|
||||
|
||||
# int function is used to transfer double var into int var
|
||||
# the normal type of number in balloon script is double
|
||||
var int=func(value)
|
||||
{
|
||||
return __call_Cpp_int(value);
|
||||
return __Cpp_inline_var_to_int(value);
|
||||
};
|
||||
|
||||
# num function is used to translate a string into a number
|
||||
var num=func(value)
|
||||
{
|
||||
return __call_Cpp_type_trans_num(value);
|
||||
};
|
||||
+4
-1
@@ -1,13 +1,16 @@
|
||||
|
||||
# the function print is written by Cpp: std::cout
|
||||
# the function input is written by Cpp: std::cin
|
||||
# so the code is fake XD but the definitions are of great use
|
||||
# the definitions are set to avoid redefinition
|
||||
# made by github user: ValKmjolnir
|
||||
|
||||
# print function use dynamic parameters
|
||||
var print=func(args...)
|
||||
{
|
||||
return __call_cpp_ostream_std_cout(args);
|
||||
};
|
||||
|
||||
# the return type of input is __var_string
|
||||
var input=func()
|
||||
{
|
||||
return __call_cpp_istream_std_cin();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# made by github user: ValKmjolnir
|
||||
|
||||
var pi=3.14159265358979;
|
||||
var ln_2=0.69314718055994530942;
|
||||
var ln_10=2.30258509299404568402;
|
||||
@@ -41,6 +43,7 @@ var pow=func(__x,__num)
|
||||
else{return exp(__num*ln(__x));}
|
||||
};
|
||||
|
||||
# sigmoid function is a normal function used in neural networks
|
||||
var sigmoid=func(__x)
|
||||
{
|
||||
return 1.0/(1+exp(-__x));
|
||||
|
||||
Reference in New Issue
Block a user