Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,22 +0,0 @@
|
|||
with Ada.Float_Text_Io; use Ada.Float_Text_Io;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Mean_Main is
|
||||
type Vector is array (Positive range <>) of Float;
|
||||
function Mean (Item : Vector) return float with pre => Item'length > 0;
|
||||
function Mean (Item : Vector) return Float is
|
||||
Sum : Float := 0.0;
|
||||
begin
|
||||
for I in Item'range loop
|
||||
Sum := Sum + Item(I);
|
||||
end loop;
|
||||
return Sum / Float(Item'Length);
|
||||
end Mean;
|
||||
A : Vector := (3.0, 1.0, 4.0, 1.0, 5.0, 9.0);
|
||||
begin
|
||||
Put(Item => Mean (A), Fore => 1, Exp => 0);
|
||||
New_Line;
|
||||
-- test for zero length vector
|
||||
Put(Item => Mean(A (1..0)), Fore => 1, Exp => 0);
|
||||
New_Line;
|
||||
end Mean_Main;
|
||||
|
|
@ -1 +0,0 @@
|
|||
FUNCTION MEAN(some-table (ALL))
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. find-mean.
|
||||
|
||||
DATA DIVISION.
|
||||
LOCAL-STORAGE SECTION.
|
||||
01 i PIC 9(4).
|
||||
|
||||
01 summ USAGE FLOAT-LONG.
|
||||
|
||||
LINKAGE SECTION.
|
||||
01 nums-area.
|
||||
03 nums-len PIC 9(4).
|
||||
03 nums USAGE FLOAT-LONG
|
||||
OCCURS 0 TO 1000 TIMES
|
||||
DEPENDING ON nums-len.
|
||||
|
||||
01 result USAGE FLOAT-LONG.
|
||||
|
||||
PROCEDURE DIVISION USING nums-area, result.
|
||||
IF nums-len = 0
|
||||
MOVE 0 TO result
|
||||
GOBACK
|
||||
END-IF
|
||||
|
||||
DIVIDE FUNCTION SUM(nums (ALL)) BY nums-len GIVING result
|
||||
|
||||
GOBACK
|
||||
.
|
||||
|
|
@ -19,7 +19,7 @@ extension op
|
|||
}
|
||||
}
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
var array := new int[]{1, 2, 3, 4, 5, 6, 7, 8};
|
||||
Console.printLine(
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
(defun mean (lst)
|
||||
(/ (float (apply '+ lst)) (length lst)))
|
||||
(mean '(1 2 3 4))
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(let ((x '(1 2 3 4)))
|
||||
(calc-eval "vmean($1)" nil (append '(vec) x)))
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
function mean(sequence s)
|
||||
atom sum
|
||||
if length(s) = 0 then
|
||||
return 0
|
||||
else
|
||||
sum = 0
|
||||
for i = 1 to length(s) do
|
||||
sum += s[i]
|
||||
end for
|
||||
return sum/length(s)
|
||||
end if
|
||||
end function
|
||||
|
||||
sequence test
|
||||
test = {1.0, 2.0, 5.0, -5.0, 9.5, 3.14159}
|
||||
? mean(test)
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
function mean ($x) {
|
||||
if ($x.Count -eq 0) {
|
||||
return 0
|
||||
} else {
|
||||
$sum = 0
|
||||
foreach ($i in $x) {
|
||||
$sum += $i
|
||||
}
|
||||
return $sum / $x.Count
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
function mean ($x) {
|
||||
if ($x.Count -eq 0) {
|
||||
return 0
|
||||
} else {
|
||||
return ($x | Measure-Object -Average).Average
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
rebol [
|
||||
Title: "Arithmetic Mean (Average)"
|
||||
URL: http://rosettacode.org/wiki/Average/Arithmetic_mean
|
||||
]
|
||||
|
||||
average: func [v /local sum][
|
||||
if empty? v [return 0]
|
||||
|
||||
sum: 0
|
||||
forall v [sum: sum + v/1]
|
||||
sum / length? v
|
||||
]
|
||||
|
||||
; Note precision loss as spread increased.
|
||||
|
||||
print [mold x: [] "->" average x]
|
||||
print [mold x: [3 1 4 1 5 9] "->" average x]
|
||||
print [mold x: [1000 3 1 4 1 5 9 -1000] "->" average x]
|
||||
print [mold x: [1e20 3 1 4 1 5 9 -1e20] "->" average x]
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
let arr = [3, 8, 4, 1, 5, 12]
|
||||
|
||||
let num = Js.Array.length(arr)
|
||||
let tot = Js.Array.reduce(\"+", 0, arr)
|
||||
let mean = float_of_int(tot) /. float_of_int(num)
|
||||
|
||||
Js.log(Js.Float.toString(mean))
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
Function mean(arr)
|
||||
size = UBound(arr) + 1
|
||||
mean = 0
|
||||
For i = 0 To UBound(arr)
|
||||
mean = mean + arr(i)
|
||||
Next
|
||||
mean = mean/size
|
||||
End Function
|
||||
|
||||
'Example
|
||||
WScript.Echo mean(Array(3,1,4,1,5,9))
|
||||
Loading…
Add table
Add a link
Reference in a new issue