Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Count to 10, /prog/

Name: Anonymous 2012-07-25 16:31

1

Name: Anonymous 2012-07-25 16:35

COUNT TO DUBS PRAWG

Name: Anonymous 2012-07-25 22:20

binary dubs check em

Name: Anonymous 2012-07-26 4:04


(let lol ((i 1))
 (display i)
 (newline)
 (cond ((= i 10) #t)
  (else (lol (+ i 1)))))

Name: Anonymous 2012-07-26 4:49

>>4
Terrible!

(prog1 t
  (loop for i from 1 upto 10
        do (print i)))

Name: Anonymous 2012-07-26 9:43

>>5
da land of lisp

Name: Anonymous 2012-07-26 12:46

1 2 3 4 5 6 7 8 9 10.

Name: Anonymous 2012-07-26 13:12

1 10 [a,b] [ . ] each

Name: Anonymous 2012-07-26 13:15

sequence_.(print<$>)$[1..10]

Name: Anonymous 2012-07-26 13:50

(doseq [i (range 1 11)] (prn i))

Name: Anonymous 2012-07-26 14:15

Count to dubs

Name: Anonymous 2012-07-26 14:36

#!/bin/bash
x=1
while [ $x -le 10 ]; do
echo "$x"
let x++
done

Name: Anonymous 2012-07-26 14:58


#include <stdio.h>

void print_number(int n)
{
switch (n) {
case 1: printf("%d\n", 1);
case 2: printf("%d\n", 2);
case 3: printf("%d\n", 3);
case 4: printf("%d\n", 4);
case 5: printf("%d\n", 5);
case 6: printf("%d\n", 6);
case 7: printf("%d\n", 7);
case 8: printf("%d\n", 8);
case 9: printf("%d\n", 9);
case 10: printf("%d\n", 10);
}
}
void print_one()
{
print_number(1);
}
void print_two()
{
print_number(2);
}
void print_three()
{
print_number(3);
}
void print_four()
{
print_number(4);
}
void print_five()
{
print_number(5);
}
void print_six()
{
print_number(6);
}
void print_seven()
{
print_number(7);
}
void print_eight()
{
print_number(8);
}
void print_nine()
{
print_number(9);
}
void print_ten()
{
print_number(10);
}
int i;
main(void)
{
i = 0;
while (i < 10)
{
switch(i)
{
case 0: print_one();
case 1: print_two();
case 2: print_three();
case 3: print_four();
case 4: print_five();
case 5: print_six();
case 6: print_seven();
case 7: print_eight();
case 8: print_nine();
case 9: print_ten();
}
i++
}
}

Name: Anonymous 2012-07-26 15:03

dc -e '0[1+pd10>x]dsxx'

Name: Anonymous 2012-07-26 15:27

for(int i=1;i<=10;i++)
printf("%d\n,i);


//Do I win?

Name: Anonymous 2012-07-26 16:33

>>13
Nice!

>>15
The solution by >>13 is better because it has optimized print function for every number.

Name: Anonymous 2012-07-26 17:00

>>16
Oh, I was going for flexibility over optimization.  How about this:

puts("1\n2\n3\n4\n5\n6\n7\n8\n9\n10");

Name: Anonymous 2012-07-26 17:08

>>17
neat

Name: Anonymous 2012-07-26 18:28

say ^10>>+>>1>>~>>"\n"

Name: Anonymous 2012-07-26 18:39

putStrLn (show [0..10])

Name: Anonymous 2012-07-26 18:59

for i in range(11):
    print i

Name: Anonymous 2012-07-26 19:09

⍳10

Name: Anonymous 2012-07-26 19:16

print ' '.join(range(11))

Name: Anonymous 2012-07-26 19:33

#include <string>
#include <vector>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

class Number
{
protected:
    unsigned num; // Extend this with bignum capabilities in the future

public:
    Number()
    {
        num = 0;
    }
   
    Number(const Number& rhs) : num(rhs.num)
    {
        // Do nothing
    }
   
    string to_string()
    {
        ostringstream os;
        os << num;
        return os.str();
    }
   
    friend class NumberIncrementer;
};

Number zero;

class NumberIncrementer
{
public:
    void increment(Number *num)
    {
        if (num == 0) {
            throw runtime_error("Unknown error.");
        }
       
        num->num = num->num + 1;
    }
};

class NumberGenerator
{
private:
    Number *num;
    NumberIncrementer *inc;

public:
    NumberGenerator()
    {
        num = new Number(zero);
        inc = new NumberIncrementer();
        inc->increment(num);
    }
   
    ~NumberGenerator()
    {
        delete num;
        delete inc;
    }
   
    bool increment()
    {
        try {
            inc->increment(num);
        } catch (exception& e) {
            return false;
        }
        return (bool)this;
    }
   
    Number get()
    {
        return *num;
    }
};

NumberGenerator ng;

struct func_t {
    void operator()(int)
    {
        Number n;
        n = ng.get();
        cout << n.to_string() << endl;
        ng.increment();
    }
} func;

int main()
{
    vector<int> i;
   
    i.push_back(1);
    i.push_back(2);
    i.push_back(3);
    i.push_back(4);
    i.push_back(5);
    i.push_back(6);
    i.push_back(7);
    i.push_back(8);
    i.push_back(9);
    i.push_back(10);
   
    for_each(i.begin(), i.end(), func);
}

Name: Anonymous 2012-07-26 19:38

for($i = 1; i < 11; i++) {
    echo $i;
}

Name: Anonymous 2012-07-27 1:04

>>24
+1 upgoated for [/i]modern C++ style[/i]

Name: >>26 2012-07-27 1:05

oh god oh god oh god, hold me /prog/. i'm sorry you had to see this.

Name: Anonymous 2012-07-27 1:23

[/i]HOLD ME PRAWG[/i]

Name: Anonymous 2012-07-27 1:38

'\n'.join('\n'.join([j for j in range(len([i for i in range(10)]))).split('\n'))

Name: Anonymous 2012-07-27 1:46

>>29
You mean

' '.join(('\n'.join([str(j) for j in range(len([i for i in range(1,11)]))])).split('\n'))

Name: Anonymous 2012-07-27 1:48

(" "):rep(10):gsub("().",print)

Name: Anonymous 2012-07-27 9:46

++++++++[->++++>++++++<<]>>+.<.>+.<.>+.<.>+.<.>+.<.>+.<.>+.<.>+.<.>+.<.>--------.-.

Don't change these.
Name: Email:
Entire Thread Thread List