Name: Anonymous 2010-06-17 15:14
Lets see if /prog/ can count to 10 in C. I'll start:
int main(void){
int main(void){
(do-ec (: i 1 11) (display i))
10 a = 0
20 a = a + 1
20 print a
40 if a = 10 then goto 60
50 goto 20
60 end
goto considered awesome.>1+::.v
| -,:a<
@<,a._@#-b:::+1
++++++[>++++++++<-]>
>++++++++++>+++++++++[<<+.>.>-]
<<--------.-.>.
(loop for i from 1 to 10 do (print i))
for i in range(1,11): print i
class one210():
def __init__(self):
self.n = 0 #ALWAYS INIT UR VARS
def count(self, by):
self.n += by
def show(self):
print self.n
one2ten = one210()
i = 0
while i < 10:
one2ten.count(1)
one2ten.show()
i += 1
say for 1..10
main = mapM_ (map show [1..10])
def PrintFunction(string):
print string
class Policies:
IncrementPolicy = 1
DecrementPolicy = 2
ProductPolicy = 3
DivisionPolicy = 4
def __init__(self, policy):
self._policy = policy
def doOperation(self, numeric, policyChange = 1):
p = self._policy
if p == self.IncrementPolicy: return numeric + policyChange
if p == self.DecrementPolicy: return numeric - policyChange
if p == self.ProductPolicy: return numeric * policyChange
if p == self.DivisionPolicy: return numeric / policyChange
def startHigh(self):
p = self._policy
if p == self.IncrementPolicy: return False
if p == self.DecrementPolicy: return True
if p == self.ProductPolicy: return False
if p == self.DivisionPolicy: return True
class Counter:
def __init__(self, policy, printFunc = PrintFunction, min = 0, max = 10, step = 1, autoReset = True):
self._min = min
self._max = max
self._step = step
self._policy = Policies(policy)
self._startHigh = self._policy.startHigh()
self._printFunc = printFunc
self._autoReset = autoReset
if self._startHigh: self._cur = max
else: self._cur = min
printFunc("%d" % self._cur)
def process(self):
self._cur = self._policy.doOperation(self._cur, self._step)
printFunc = self._printFunc
printFunc("%d" % self._cur)
if self._startHigh and self._cur <= self._min:
printFunc("Finished iteration")
if self._autoReset:
self._cur = self._max
printFunc("Restarting")
else: return False
elif not self._startHigh and self._cur >= self._max:
printFunc("Finished iteration")
if self._autoReset:
self._cur = self._min
printFunc("Restarting")
else: return False
return True
def TestSuite(oneBased = False):
y = 0
if oneBased: y = 1
x = Counter(Policies.IncrementPolicy, PrintFunction, y, 10, 1, False)
while x.process():
continue
TestSuite()
#lang scheme
(define (count-from start end)
(if (= start end)
(and(newline)end)
(and (newline)
(display start)
(count-from (inc start) end))))
(define (inc x)
(+ x 1))
(count-from 1 100)
and instead of begin 10.times {|x| puts "#{x+1}\n"}
#!/usr/bin/perl
for (1..10) print "$_\n";
#!/usr/bin/perl
for (1..10) { print "$_\n" };
Α ← 0 Β ← 1 α ← 1 β ← 1 « α ≯ 10 α → Λ + → α »