L A library of simple mathematical functions written in scripting languages

Source: Internet
Author: User
Tags mathematical functions

The function of mathematical computation in a programming language is of course essential, and it is simple to implement the mathematical Computing Library through the basic mathematical functions of the L scripting language.

In the L scripting language, you need to import the library before using it, which is similar to the C-language import jar package that references java.


The following example is a library file for an L scripting language


#scplib
#数学函数库

Definition: function, the circumference of the circle, radius
Start: function to find the perimeter of a circle
Calculation: formula, ret,2*3.14* radius
Display: RET
End: function to find the circumference of a circle

Definition: function, area of circle, radius
Start: function to find the area of a circle
Calculation: Formula, ret,3.14* (RADIUS * radius)
Display: RET
End: function to find the area of a circle

Definition: function, exponentiation, NUM1
Start: function, exponentiation
Calculation: Formula, RET,NUM1*NUM1
Display: RET
End: function, exponentiation

Definition: function, square, NUM1
Start: function, square
Calculation: Formula, RET,NUM1*NUM1
Display: RET
End: function, square

Definition: function, three times, NUM1
Start: function, three-time Square
Calculation: Formula, RET,NUM1*NUM1*NUM1
Display: RET
End: function, three-time Square

Definition: function, remainder, num1,num2
Start: function, find remainder
Calculation: Formula, ret,num1%num2
Display: RET
End: function, seek remainder

Definition: function, the average of three numbers, n1,n2,n3
Start: function, calculate the average of three numbers
Calculation: Equation, eee, (N1+N2+N3)/3
Display: eee
End: function, averaging of three numbers


The following script file is an example program that uses the above library of mathematical functions


#scp
Import: library, D:\SCRIPTENGINE\SCRIPTS\TESTSCRIPT_NUMERIC_LIB.SCP
Definitions: integers, rid2,10
Definitions: integers, rid,100
Definitions: integers, number1,8
Definitions: integers, number2,9
Definitions: integers, number3,100
Show: "Now the circumference of the circle"
Call: function, round perimeter, RID
Show: "Now the area of the circle"
Call: function, Rid2 area of the circle,
Invoke: Function, exponentiation, number1
Call: function, seek remainder, Number2,number1
Call: function, three-time Square, number1
Call: function, the average of three numbers, Number1,number2,number3
Call: function, average of three numbers, 100,200,300


Definition: String, user-entered string
Wait: User input, user input string

L A library of simple mathematical functions written in scripting languages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.