Difference between revisions of "Wolfram (programming language)"

From Bauman National Library
(Examples)
Line 61: Line 61:
 
Examples of the different programs:
 
Examples of the different programs:
  
<syntaxhighlight lang="Wolfram">
+
<syntaxhighlight lang:="Wolfram">
 
F=GF[2];PowerListQ[GF[2]]=True;
 
F=GF[2];PowerListQ[GF[2]]=True;
 
{table,CD,L}=BM[{0,F[{1}],0,F[{1}],F[{1}],0,F[{1}],0,0,F[{1}]},F];
 
{table,CD,L}=BM[{0,F[{1}],0,F[{1}],F[{1}],0,F[{1}],0,0,F[{1}]},F];

Revision as of 13:25, 2 June 2016

Nim
Paradigm multi-paradigm: term-rewriting, functional, procedural, array
Designed by Stephen Wolfram
Developer Wolfram Research
First appeared 2013
Typing discipline dynamic, strong
Website www.wolfram.com/language
Influenced by
Mathematica
Influenced
Julia

Wolfram- а very general comparison of multi-paradigm programming languages. Language developed by Wolfram Research. It serves as the main link language for the Mathematica system. Its creators have laid into him the opportunity to realize arbitrary structures and data. It was designed as the most universal language, with an emphasis on symbolic computation, functional and logic programming.

History

Stephen Wolfram is a British scientist known for his work in the field of elementary particle physics, and cellular automata, computer science and mathematics. He is the author of the book «A New Kind of Science" and the creator of the application based on the Mathematica software and Wolfram Alpha, developed in 2009, is an online service.

Basic rule

Basic rule of language are:

  • Scientific programming is based on the maximum knowledge.
  • Meta algorithms: the maximum possible automation.
  • Consistency: language supports a unified and elegant design.
  • Symbolic representation: all (data, formulas, graphics code, documents) are presented in the form of symbolic expressions.
  • Model of the world: Language Tungsten has built a broad model of the world through Wolfram Alpha.
  • Versatile Deployment: Deploy language on any platform.
  • Built-in connectivity to a wide range of languages, services, programs, and devices using Wolfram Cloud.
  • Interactivity.
  • Fully scalable: enables scaling programs with one line with millions of rows and independent use for a broad public deployment.

Examples

The code to calculate 2+2

ln[] = 2+2

The code to reverse the word “rhinoceros”:

ln[] = StringReverse["rhinoceros"]

Change the font family:

ln[] = ImageReflect[Rasterize[Style["name",40,FontFamily->"Comic Sans MS"]],Left->Right]

Draw a size 100 disk:

ln[] =Graphics[Disk[],ImageSize->100]

Examples of the different programs:

F=GF[2];PowerListQ[GF[2]]=True;
{table,CD,L}=BM[{0,F[{1}],0,F[{1}],F[{1}],0,F[{1}],0,0,F[{1}]},F];
table//TableForm
Print["C(D)=",Simplify[CD],"; L=", L];
n	s^(n+1)	\[Delta]	C(D)	2L<=n	C^*(D)	L	\[Delta]^*	\[Lambda]
	Initial loading:		1		1	0	1	1
F=GF[2,{1,1,0,0,1}];PowerListQ[GF[2,{1,1,0,0,1}]]=True;
{table,CD,L}=BM[{FieldExp[F,8],FieldExp[F,6],FieldExp[F,11],FieldExp[F,5]},F];
table//TableForm
Print["C(D)=",Simplify[CD],"; L=", L];
n	s^(n+1)	\[Delta]	C(D)	2L<=n	C^*(D)	L	\[Delta]^*	\[Lambda]
	Initial loading:		1		1	0	1	1
0	\[Alpha]^8	\[Alpha]^8	1\[Alpha]^8	+	1	1	\[Alpha]^8	1
1	\[Alpha]^8\[Alpha]^6	\[Alpha]^11	1\[Alpha]^13	-				2
2	\[Alpha]^8\[Alpha]^6\[Alpha]^11	\[Alpha]^13	1\[Alpha]^13\[Alpha]^5	+	1\[Alpha]^13	2	\[Alpha]^13	1
3	\[Alpha]^8\[Alpha]^6\[Alpha]^11\[Alpha]^5	\[Alpha]^1	1\[Alpha]^8\[Alpha]^2	-				2

Examples of various programs:

F=GF[2];PowerListQ[GF[2]]=True;
{table,CD,L}=BM[{0,F[{1}],0,F[{1}],F[{1}],0,F[{1}],0,0,F[{1}]},F];
table//TableForm
Print["C(D)=",Simplify[CD],"; L=", L];
n	s^(n+1)	\[Delta]	C(D)	2L<=n	C^*(D)	L	\[Delta]^*	\[Lambda]
	Initial loading:		1		1	0	1	1
F=GF[2,{1,1,0,0,1}];PowerListQ[GF[2,{1,1,0,0,1}]]=True;
{table,CD,L}=BM[{FieldExp[F,8],FieldExp[F,6],FieldExp[F,11],FieldExp[F,5]},F];
table//TableForm
Print["C(D)=",Simplify[CD],"; L=", L];
n	s^(n+1)	\[Delta]	C(D)	2L<=n	C^*(D)	L	\[Delta]^*	\[Lambda]
	Initial loading:		1		1	0	1	1
0	\[Alpha]^8	\[Alpha]^8	1\[Alpha]^8	+	1	1	\[Alpha]^8	1
1	\[Alpha]^8\[Alpha]^6	\[Alpha]^11	1\[Alpha]^13	-				2
2	\[Alpha]^8\[Alpha]^6\[Alpha]^11	\[Alpha]^13	1\[Alpha]^13\[Alpha]^5	+	1\[Alpha]^13	2	\[Alpha]^13	1
3	\[Alpha]^8\[Alpha]^6\[Alpha]^11\[Alpha]^5	\[Alpha]^1	1\[Alpha]^8\[Alpha]^2	-				2

Berlekamp-Massey algorithm, implemented on Wolfram

<<FiniteFields`
BM[s_,fld_]:=Module[
    {CD=fld[{1}],CDA=fld[{1}],L=0,\[Delta],\[Delta]A=fld[{1}],\[Lambda]=1,TD,table={}},

    table = Append[table,{"n","s^(n+1)","\[Delta]","C(D)","2L<=n","C^*(D)","L","\[Delta]^*","\[Lambda]"}];
    table = Append[table,{"","Initial loading:", "", "1", "","1", "0","1","1"}];

    For[n=0,n<Length[s],n++,

        sn = s[[;;n+1]];

        \[Delta] = PadRight[CoefficientList[CD,D],L+1].PadRight[Reverse[sn],L+1];

        table = Append[table,{n,StringJoin[ToString[If[FieldInd[#]==-Infinity,0,If[FieldInd[#]==0,1,Superscript[\[Alpha],FieldInd[#]]]],TraditionalForm]&amp;/@sn],ToString[If[FieldInd[\[Delta]]==-Infinity,0,If[FieldInd[\[Delta]]==0,1,Superscript[\[Alpha],FieldInd[\[Delta]]]]],TraditionalForm]}];

        If[FieldInd[\[Delta]]==-Infinity,

            \[Lambda] += 1;
            table[[n+3]] = Join[table[[n+3]],{"","","","","",\[Lambda]}],

            TD=CD;
            CD-=\[Delta]/\[Delta]A*D^\[Lambda]*CDA;

            If[2*L<=n,

                L=n+1-L;
                \[Lambda] = 1; \[Delta]A = \[Delta];
                CDA = TD;
                table[[n+3]] = Join[table[[n+3]],{StringJoin[ToString[If[FieldInd[#]==-Infinity,0,If[FieldInd[#]==0,1,Superscript[\[Alpha],FieldInd[#]]]],TraditionalForm]&amp;/@CoefficientList[CD,D]],"+",StringJoin[ToString[If[FieldInd[#]==-Infinity,0,If[FieldInd[#]==0,1,Superscript[\[Alpha],FieldInd[#]]]],TraditionalForm]&amp;/@CoefficientList[CDA,D]],L,ToString[If[FieldInd[\[Delta]A]==-Infinity,0,If[FieldInd[\[Delta]A]==0,1,Superscript[\[Alpha],FieldInd[\[Delta]A]]]],TraditionalForm],\[Lambda]}],

                \[Lambda] += 1;
                table[[n+3]] = Join[table[[n+3]], {StringJoin[ToString[If[FieldInd[#]==-Infinity,0,If[FieldInd[#]==0,1,Superscript[\[Alpha],FieldInd[#]]]],TraditionalForm]&amp;/@CoefficientList[CD,D]],"-","","","",\[Lambda]}];

            ];
        ];
    ];
    Return[{table,CD,L},Module]
];

External links

  1. Documentation for the Wolfram Language
  2. An Elementary Introduction to the Wolfram Language
  3. The Wolfram Programming Cloud
  4. WolframLanguage.org
  5. A list of open-source implementations of the Wolfram language