Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -0,0 +1,6 @@
factorial:
1
while over:
* over
swap -- swap
drop swap

View file

@ -0,0 +1,5 @@
factorial:
if dup:
* factorial -- dup
else:
1 drop

View file

@ -1 +1 @@
fact(n) = prod(1:big(n))
fact(n) = prod(one(n):n)

View file

@ -0,0 +1 @@
answer = factorial(N)

View file

@ -0,0 +1,30 @@
use std.textio.all;
entity rc is
end entity rc;
architecture beh of rc is
function fact(n:integer) return integer is
variable f: integer := 1;
variable i: integer;
begin
for i in 2 to n loop
f := f*i;
end loop;
return f;
end;
begin
process
variable i: integer;
variable l: line;
begin
for i in 0 to 5 loop
write(l, i);
write(l, string'(" "));
write(l, fact(i));
writeline(output, l);
end loop;
wait;
end process;
end;