FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/PascalABC.NET

PascalABC.NET

Contents
Code examples
    Usual PascalABC.NET style
    Object-oriented style
    Close to regular C# style

PascalABC.NET
ParadigmMulti-paradigm: procedural, functional, object-oriented, generic
Designed byPascalABC.NET Compiler Team
First appeared2007;19 years ago (2007)
loop10do Write('*');

• for loop with a step

(1..10).Printlines

• short function definition syntax

varseq:sequenceofinteger:=Arr(1..10); seq.Println; seq:=Lst(11..100);seq.Println; seq:=HSet(1..20);seq.Println;

• lambda functions

i*i);\n"}}'>vara:=ArrGen(10,i->i*i);

• auto classes - classes with an automatically generated constructor

##// denotes that the main program will be written without enclosing begin-end varf:real->real:=x->x*x;

Here is an example of superposition of two functions:

(f: T1 -> T2; g: T -> T1): T -> T2 := x -> f(g(x));\n\nvar f: real -> real := x -> x*x;\nvar fg := Super(f,Sin);\nvar gf := Super(Sin,f);\n\nPrint(fg(2));\nPrint(gf(2));\n"}}'>## functionSuper<T,T1,T2>(f:T1->T2;g:T->T1):T->T2:=x->f(g(x)); varf:real->real:=x->x*x; varfg:=Super(f,Sin); vargf:=Super(Sin,f); Print(fg(2)); Print(gf(2));

Superposition operation is defined in the standard library:

real := x -> x*x;\n\nPrint((f*Cos)(2));\nPrint((Cos*f)(2));\n"}}'>## varf:real->real:=x->x*x; Print((f*Cos)(2)); Print((Cos*f)(2));

In the book "How To Program Effectively In Delphi" and in the corresponding video tutorials, Dr. Kevin Bond, a programmer and a Computer Science teaching specialist, notes that PascalABC.NET has powerful functional programming capabilities which are missing in Delphi. As an example, partial function application is demonstrated:

integer -> integer := x -> y -> x + y;\n Writeln(f(2)(6));\nend.\n"}}'>begin varf:integer->integer->integer:=x->y->x+y; Writeln(f(2)(6)); end.

Code examples

edit

PascalABC.NET is a multi-paradigm programming language. It allows one to use different coding styles from oldschool Pascal to functional and object-oriented programming. The same task can be solved in different styles as follows:

Usual PascalABC.NET style

edit
begin var(a,b):=ReadInteger2; (a..b).Sum(x->x*x).Print// method chaining with lambda expressions end.

Object-oriented style

edit

This solution demonstrates PascalABC.NET-specific short function definition style.

x*x); \n static function SumCubes(a,b: integer) := (a..b).Sum(x -> x*x*x);\nend;\n\nbegin\n var (a,b) := ReadInteger2;\n Println($'Squares sum = {Algorithms.SumSquares(a,b)}');\n Println($'Cubes sum = {Algorithms.SumCubes(a,b)}') \nend.\n"}}'>typeAlgorithms=class staticfunctionSumSquares(a,b:integer):=(a..b).Sum(x->x*x); staticfunctionSumCubes(a,b:integer):=(a..b).Sum(x->x*x*x); end; begin var(a,b):=ReadInteger2; Println($'Squares sum = {Algorithms.SumSquares(a,b)}'); Println($'Cubes sum = {Algorithms.SumCubes(a,b)}') end.

Close to regular C# style

edit

It is possible to write programs without usage of PascalABC.NET standard library. All standard .NET Framework classes and methods can be used directly.

"Twisted Pair Podcast, #389". Twisted Pair Podcast (in Russian). 30 March 2021.
  • ↑ "Re-checking PascalABC.NET". Medium. 11 February 2022.
  • ↑ Polyakov, Konstantin. "Doklady na konferenciyah i seminarah [Reports at conferences and seminars]" (in Russian).
  • 1 2 3 4 Dzhenzher, V.O.; Denisova, L.V. (2021). "Implementation of the Hamming code on PascalABC.NET while studying the theoretical foundations of informatics". Informatics in School (in Russian). 1 (9): 29–38. doi:10.32517/2221-1993-2021-20-9-27-36. S2CID 245473319.
  • ↑ Khazieva, R.T.; Ivanov, M.D. (2020). "Selection of optimum device parameters for permanent magnetic field generation". Power Engineering: Research, Equipment, Technology (in Russian). 22 (6): 176–187. doi:10.30724/1998-9903-2020-22-6-176-187. S2CID 233658494.
  • ↑ "Yandex Contest Compilers List". Yandex Contest. Archived from the original on 14 March 2023. Retrieved 5 April 2023.
  • ↑ "Mengenal PascalABC.NET". Archived from the original on 10 August 2022. Retrieved 8 April 2023.
  • ↑ Kevin R. Bond (2021). "Chapter 44. Anonymous methods". How to Program Effectively in Delphi for AS/A Level Computer Science. Educational Computing Services Ltd. ISBN 9780992753603.
  • ↑ "Brief biography Dr Kevin R Bond" (PDF). Educational Computing Services Ltd. Archived from the original (PDF) on 4 April 2023. Retrieved 4 April 2023.
  • ↑ "Nauchno-metodicheskaya konferenciya «Ispol'zovanie sistemy programmirovaniya PascalABC.NET v obuchenii programmirovaniyu» (29-30 marta 2023 g.) [Scientific and methodical conference "Using PascalABC.NET programming system in teaching programming" (March 29-30, 2023)]". Institute of Mathematics, Mechanics, and Computer Science (in Russian). Retrieved 10 April 2023.
  • ↑ Polyakov, Konstantin (24 August 2021). "New features in PascalABC.NET" (in Russian).
  • ↑

  • View original on Wikipedia | Back | FazBrowse Home