Dispaying the number of elements in an array
ID: 46
See: Count = [Int64]
using uCalcSoftware;
var uc = new uCalc();
static void MyAverage(uCalc.Callback cb) {
double Total = 0;
for (int x = 1; x <= cb.ArgCount(); x++) {
Total = Total + cb.Arg(x);
}
cb.Return(Total / cb.ArgCount());
}
var MyArrayA = uc.DefineVariable("MyArrayA[] = {10, 20, 30, 40, 50}");
var MyArrayB = uc.DefineVariable("MyArrayB[15]");
var FunctionA = uc.DefineFunction("FuncA(x, y, z) = x + y + z");
var FunctionB = uc.DefineFunction("FuncB(x, y, a = 12, b = 34) = x+y+a+b");
var FunctionC = uc.DefineFunction("FuncC(x, y ...)", MyAverage);
var FunctionD = uc.DefineFunction("FuncD() = 1+1");
Console.WriteLine($"Elements in MyArrayA: {MyArrayA.Count}");
Console.WriteLine($"Elements in MyArrayB: {MyArrayB.Count}");
Console.WriteLine($"Params in FuncA(): {FunctionA.Count}");
Console.WriteLine($"Params in FuncB(): {FunctionB.Count}");
Console.WriteLine($"Params in FuncC(): {FunctionC.Count}"); // -1 or 2^n-1 (n=32 or 64)
Console.WriteLine($"Params in FuncD(): {FunctionD.Count}");
Console.WriteLine($"Operands in ! operator: {uc.ItemOf("!").Count}");
Console.WriteLine($"Operands in > operator: {uc.ItemOf(">").Count}");
Elements in MyArrayA: 5
Elements in MyArrayB: 15
Params in FuncA(): 3
Params in FuncB(): 4
Params in FuncC(): -1
Params in FuncD(): 0
Operands in ! operator: 1
Operands in > operator: 2 using uCalcSoftware; var uc = new uCalc(); static void MyAverage(uCalc.Callback cb) { double Total = 0; for (int x = 1; x <= cb.ArgCount(); x++) { Total = Total + cb.Arg(x); } cb.Return(Total / cb.ArgCount()); } var MyArrayA = uc.DefineVariable("MyArrayA[] = {10, 20, 30, 40, 50}"); var MyArrayB = uc.DefineVariable("MyArrayB[15]"); var FunctionA = uc.DefineFunction("FuncA(x, y, z) = x + y + z"); var FunctionB = uc.DefineFunction("FuncB(x, y, a = 12, b = 34) = x+y+a+b"); var FunctionC = uc.DefineFunction("FuncC(x, y ...)", MyAverage); var FunctionD = uc.DefineFunction("FuncD() = 1+1"); Console.WriteLine($"Elements in MyArrayA: {MyArrayA.Count}"); Console.WriteLine($"Elements in MyArrayB: {MyArrayB.Count}"); Console.WriteLine($"Params in FuncA(): {FunctionA.Count}"); Console.WriteLine($"Params in FuncB(): {FunctionB.Count}"); Console.WriteLine($"Params in FuncC(): {FunctionC.Count}"); // -1 or 2^n-1 (n=32 or 64) Console.WriteLine($"Params in FuncD(): {FunctionD.Count}"); Console.WriteLine($"Operands in ! operator: {uc.ItemOf("!").Count}"); Console.WriteLine($"Operands in > operator: {uc.ItemOf(">").Count}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
void ucalc_call MyAverage(uCalcBase::Callback cb) {
double Total = 0;
for (int x = 1; x <= cb.ArgCount(); x++) {
Total = Total + cb.Arg(x);
}
cb.Return(Total / cb.ArgCount());
}
int main() {
uCalc uc;
auto MyArrayA = uc.DefineVariable("MyArrayA[] = {10, 20, 30, 40, 50}");
auto MyArrayB = uc.DefineVariable("MyArrayB[15]");
auto FunctionA = uc.DefineFunction("FuncA(x, y, z) = x + y + z");
auto FunctionB = uc.DefineFunction("FuncB(x, y, a = 12, b = 34) = x+y+a+b");
auto FunctionC = uc.DefineFunction("FuncC(x, y ...)", MyAverage);
auto FunctionD = uc.DefineFunction("FuncD() = 1+1");
cout << "Elements in MyArrayA: " << MyArrayA.Count() << endl;
cout << "Elements in MyArrayB: " << MyArrayB.Count() << endl;
cout << "Params in FuncA(): " << FunctionA.Count() << endl;
cout << "Params in FuncB(): " << FunctionB.Count() << endl;
cout << "Params in FuncC(): " << FunctionC.Count() << endl; // -1 or 2^n-1 (n=32 or 64)
cout << "Params in FuncD(): " << FunctionD.Count() << endl;
cout << "Operands in ! operator: " << uc.ItemOf("!").Count() << endl;
cout << "Operands in > operator: " << uc.ItemOf(">").Count() << endl;
}
Elements in MyArrayA: 5
Elements in MyArrayB: 15
Params in FuncA(): 3
Params in FuncB(): 4
Params in FuncC(): -1
Params in FuncD(): 0
Operands in ! operator: 1
Operands in > operator: 2 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call MyAverage(uCalcBase::Callback cb) { double Total = 0; for (int x = 1; x <= cb.ArgCount(); x++) { Total = Total + cb.Arg(x); } cb.Return(Total / cb.ArgCount()); } int main() { uCalc uc; auto MyArrayA = uc.DefineVariable("MyArrayA[] = {10, 20, 30, 40, 50}"); auto MyArrayB = uc.DefineVariable("MyArrayB[15]"); auto FunctionA = uc.DefineFunction("FuncA(x, y, z) = x + y + z"); auto FunctionB = uc.DefineFunction("FuncB(x, y, a = 12, b = 34) = x+y+a+b"); auto FunctionC = uc.DefineFunction("FuncC(x, y ...)", MyAverage); auto FunctionD = uc.DefineFunction("FuncD() = 1+1"); cout << "Elements in MyArrayA: " << MyArrayA.Count() << endl; cout << "Elements in MyArrayB: " << MyArrayB.Count() << endl; cout << "Params in FuncA(): " << FunctionA.Count() << endl; cout << "Params in FuncB(): " << FunctionB.Count() << endl; cout << "Params in FuncC(): " << FunctionC.Count() << endl; // -1 or 2^n-1 (n=32 or 64) cout << "Params in FuncD(): " << FunctionD.Count() << endl; cout << "Operands in ! operator: " << uc.ItemOf("!").Count() << endl; cout << "Operands in > operator: " << uc.ItemOf(">").Count() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub MyAverage(ByVal cb As uCalc.Callback)
Dim Total As Double = 0
For x As Integer = 1 To cb.ArgCount()
Total = Total + cb.Arg(x)
Next
cb.Return(Total / cb.ArgCount())
End Sub
Public Sub Main()
Dim uc As New uCalc()
Dim MyArrayA = uc.DefineVariable("MyArrayA[] = {10, 20, 30, 40, 50}")
Dim MyArrayB = uc.DefineVariable("MyArrayB[15]")
Dim FunctionA = uc.DefineFunction("FuncA(x, y, z) = x + y + z")
Dim FunctionB = uc.DefineFunction("FuncB(x, y, a = 12, b = 34) = x+y+a+b")
Dim FunctionC = uc.DefineFunction("FuncC(x, y ...)", AddressOf MyAverage)
Dim FunctionD = uc.DefineFunction("FuncD() = 1+1")
Console.WriteLine($"Elements in MyArrayA: {MyArrayA.Count}")
Console.WriteLine($"Elements in MyArrayB: {MyArrayB.Count}")
Console.WriteLine($"Params in FuncA(): {FunctionA.Count}")
Console.WriteLine($"Params in FuncB(): {FunctionB.Count}")
Console.WriteLine($"Params in FuncC(): {FunctionC.Count}") '// -1 or 2^n-1 (n=32 or 64)
Console.WriteLine($"Params in FuncD(): {FunctionD.Count}")
Console.WriteLine($"Operands in ! operator: {uc.ItemOf("!").Count}")
Console.WriteLine($"Operands in > operator: {uc.ItemOf(">").Count}")
End Sub
End Module
Elements in MyArrayA: 5
Elements in MyArrayB: 15
Params in FuncA(): 3
Params in FuncB(): 4
Params in FuncC(): -1
Params in FuncD(): 0
Operands in ! operator: 1
Operands in > operator: 2 Imports System Imports uCalcSoftware Public Module Program Public Sub MyAverage(ByVal cb As uCalc.Callback) Dim Total As Double = 0 For x As Integer = 1 To cb.ArgCount() Total = Total + cb.Arg(x) Next cb.Return(Total / cb.ArgCount()) End Sub Public Sub Main() Dim uc As New uCalc() Dim MyArrayA = uc.DefineVariable("MyArrayA[] = {10, 20, 30, 40, 50}") Dim MyArrayB = uc.DefineVariable("MyArrayB[15]") Dim FunctionA = uc.DefineFunction("FuncA(x, y, z) = x + y + z") Dim FunctionB = uc.DefineFunction("FuncB(x, y, a = 12, b = 34) = x+y+a+b") Dim FunctionC = uc.DefineFunction("FuncC(x, y ...)", AddressOf MyAverage) Dim FunctionD = uc.DefineFunction("FuncD() = 1+1") Console.WriteLine($"Elements in MyArrayA: {MyArrayA.Count}") Console.WriteLine($"Elements in MyArrayB: {MyArrayB.Count}") Console.WriteLine($"Params in FuncA(): {FunctionA.Count}") Console.WriteLine($"Params in FuncB(): {FunctionB.Count}") Console.WriteLine($"Params in FuncC(): {FunctionC.Count}") '// -1 or 2^n-1 (n=32 or 64) Console.WriteLine($"Params in FuncD(): {FunctionD.Count}") Console.WriteLine($"Operands in ! operator: {uc.ItemOf("!").Count}") Console.WriteLine($"Operands in > operator: {uc.ItemOf(">").Count}") End Sub End Module