Equilibrium index: Difference between revisions

Added Easylang
(add RPL)
(Added Easylang)
 
(7 intermediate revisions by 4 users not shown)
Line 698:
</pre>
 
=={{header|BASIC256BASIC}}==
==={{header|BASIC256}}===
{{trans|Ring}}
<syntaxhighlight lang="vb">arraybase 1
Line 993 ⟶ 994:
=={{header|Delphi}}==
See [https://rosettacode.org/wiki/Equilibrium_index#Pascal Pascal].
 
=={{header|EasyLang}}==
<syntaxhighlight>
func[] equind a[] .
for v in a[]
sumr += v
.
for i to len a[]
sumr -= a[i]
if suml = sumr
r[] &= i
.
suml += a[i]
.
return r[]
.
print equind [ -7 1 5 2 -4 3 0 ]
</syntaxhighlight>
{{out}}
<pre>
[ 4 7 ]
</pre>
 
=={{header|Elena}}==
ELENA 56.0x :
<syntaxhighlight lang="elena">import extensions;
import system'routines;
Line 1,027 ⟶ 1,050:
while(en.next())
{
var element := *en.get();
right -= element;
bool found := (left == right);
Line 1,054 ⟶ 1,077:
}
get Value() = index;
enumerable() => en;
Line 1,062 ⟶ 1,085:
{
EquilibriumEnumerator.new(new int[]{ -7, 1, 5, 2, -4, 3, 0 })
.forEach:(printingLn)
}</syntaxhighlight>
<pre>
Line 1,244 ⟶ 1,267:
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Equilibrium_index}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
 
[[File:Fōrmulæ - Equilibrium index 01.png]]
 
In Fōrmulæ, indices are 1-based so the output of this program will be shifted up by one compared to solutions in languages with 0-based arrays.
 
'''Test cases'''
 
[[File:Fōrmulæ - Equilibrium index 02.png]]
 
[[File:Fōrmulæ - Equilibrium index 03.png]]
 
[[File:Fōrmulæ - Equilibrium index 04.png]]
 
[[File:Fōrmulæ - Equilibrium index 05.png]]
 
[[File:Fōrmulæ - Equilibrium index 06.png]]
 
[[File:Fōrmulæ - Equilibrium index 07.png]]
 
[[File:Fōrmulæ - Equilibrium index 08.png]]
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
[[File:Fōrmulæ - Equilibrium index 09.png]]
In '''[https://formulae.org/?example=Equilibrium_index this]''' page you can see the program(s) related to this task and their results.
 
=={{header|Go}}==
Line 3,028 ⟶ 3,071:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var equilibrium = Fn.new { |a|
Line 3,055 ⟶ 3,098:
System.print("The equilibrium indices for the following sequences are:\n")
for (test in tests) {
SystemFmt.print("%(Fmt.s(24$24n -> $n", test)), -> %(equilibrium.call(test))")
}</syntaxhighlight>
 
1,978

edits