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

@ -1,5 +1,3 @@
<cfset i = 1024 />
<cfloop condition="i GT 0">
#i#< br />
<cfset i = 1024 /><cfloop condition="i GT 0"> #i#< br />
<cfset i /= 2 />
</cfloop>

View file

@ -1,5 +1,4 @@
<cfscript>
i = 1024;
<cfscript> i = 1024;
while( i > 0 )
{
writeOutput( i + "< br/ >" );

View file

@ -1,4 +1,3 @@
%% Implemented by Arjun Sunel
-module(while).
-export([loop/0]).

View file

@ -0,0 +1,5 @@
n := 1024;
while n > 0 do
Print(n, "\n");
n := QuoInt(n, 2);
od;

View file

@ -1,22 +1,12 @@
> n := 1024: while n > 0 do print(n); n := iquo(n,2) end:
1024
512
256
128
64
32
16
8
4
2
1

View file

@ -0,0 +1,6 @@
var a = 5;
var i = 0;
while(i < a) {
i = i + 1;
}

View file

@ -1,6 +1,7 @@
/*REXX program to show a DO WHILE construct. */
j=1024
do while j>0
say j
j=j%2 /*in REXX, % is integer division. */
end
/*REXX program demonstrates a DO WHILE with index reduction construct.*/
j=1024 /*define the initial value of J.*/
do while j>0 /*test if made at the top of DO.*/
say j
j=j%2 /*in REXX, % is integer division.*/
end
/*stick a fork in it, we're done.*/

View file

@ -1,6 +1,7 @@
/*REXX program to show a DO WHILE construct. */
x=1024
do while x>0
say right(x,10) /*pretty up the output by aligning.*/
x=x%2 /*in REXX, % is integer division. */
end
/*REXX program demonstrates a DO WHILE with index reduction construct.*/
x=1024 /*define the initial value of X.*/
do while x>0 /*test if made at the top of DO.*/
say right(x,10) /*pretty output by aligning right*/
x=x%2 /*in REXX, % is integer division.*/
end
/*stick a fork in it, we're done.*/

View file

@ -1,6 +1,7 @@
/*REXX program to show a DO WHILE construct. */
x=1024
do while x>>0 /*this is an exact comparison. */
say right(x,10) /*pretty up the output by aligning.*/
x=x%2 /*in REXX, % is integer division. */
end
/*REXX program demonstrates a DO WHILE with index reduction construct.*/
x=1024 /*define the initial value of X.*/
do while x>>0 /*this is an exact comparison. */
say right(x,10) /*pretty output by aligning right*/
x=x%2 /*in REXX, % is integer division.*/
end
/*stick a fork in it, we're done.*/

View file

@ -0,0 +1,7 @@
/*REXX program demonstrates a DO WHILE with index reduction construct.*/
/* [↓] note: BY defaults to 1*/
do j=1024 by 0 while j>>0 /*this is an exact comparison. */
say right(j,10) /*pretty output by aligning right*/
j=j%2 /*in REXX, % is integer division.*/
end
/*stick a fork in it, we're done.*/

View file

@ -0,0 +1,11 @@
#lang racket
(define-syntax-rule (while condition body ...)
(let loop ()
(when condition
body ...
(loop))))
(define n 0)
(while (< n 10)
(displayln n)
(set! n (add1 n)))

View file

@ -0,0 +1,8 @@
@tailrec
def loop(iter: Int) {
if ((iter > 0)) {
println(iter)
loop(iter / 2)
}
}
loop(1024)

View file

@ -0,0 +1,6 @@
def loop = new Iterator[Int] {
var i = 1024
def hasNext = i > 0
def next(): Int = { val tmp = i; i = i / 2; tmp }
}
loop.foreach(println(_))

View file

@ -0,0 +1,2 @@
def loop(i: Int): Stream[Int] = i #:: (if (i > 0) loop(i / 2) else Stream.empty)
loop(1024).takeWhile(_ > 0).foreach(println(_))

View file

@ -0,0 +1,6 @@
i = 1024
while (i > 0)
{
Print(i)
i = (i / 2).Floor()
}