•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Software Developers' Lounge section within the Software Development category of DaniWeb, a massive community of 401,713 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,126 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 12311 | Replies: 81
![]() |
Well, since the goal is to PRINT 1 - 10, I give you:
PostScript
PostScript
%!PS
% position constants and procs
/x 72 def
/yPos 700 def
/y {yPos lnHeight sub dup /yPos exch def} bind def
% font constants
/fontName /Courier def
/ptSize 12 def
/lnHeight ptSize 1.2 mul def
% set the font
fontName ptSize selectfont
% for loop to paint numbers
1 1 10 { 5 string cvs x y moveto show} for
% commit page image to currentpage
showpage•
•
Join Date: Apr 2006
Location: San Luis Obispo, CA
Posts: 34
Reputation:
Rep Power: 3
Solved Threads: 0
In C
#include <stdio.h>
#define MIN_RANGE 1
#define MAX_RANGE 10
int main (void)
{
int i;
for (i = MIN_RANGE; i <= MAX_RANGE; i++)
printf("%i\n", i);
return 0;
} I would've done one in Tama, but it's not Turing complete so doesn't deserve it.
Ruby:
Ruby:
(1..10).each { |x| puts x }•
•
Join Date: May 2006
Location: Ontario, Canada
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 2
•
•
•
•
Jess, was this thread inspire by the one on PFO.
Of course not.

Bah, I wanted to be the first to use Ruby. Anyways...
Ruby
puts *(1..10)
--Jessehk
Here's um, another Scheme version:
And another...
(let loop ((i 1))
(cond ((<= i 10)
(display i)
(loop (+ i 1))))(define (range n m)
(if (> n m)
'()
(cons n (range (+ n 1) m))))
(for-each display (range 1 10))•
•
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation:
Rep Power: 9
Solved Threads: 18
Ohhh yeahh. Predicates with internal state.
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
template <class T>
inline void PRINT_ELEMENTS(const T& coll, const char* optc="")
{
std::cout << optc;
typename T::const_iterator pos;
for (pos=coll.begin(); pos != coll.end(); ++pos)
{
std::cout << *pos << " ";
}
}
class IntSequence
{
public:
//constructor
IntSequence(int initialValue)
: value(initialValue) { }
//function call
int operator() ()
{
return value++;
}
private:
int value;
};
int main()
{
list<int> coll;
//insert values from 1 to 9
generate_n(back_inserter(coll), //start
10, //number of elements
IntSequence(1)); //generates values
PRINT_ELEMENTS(coll);
cout << endl;
}•
•
Join Date: May 2006
Location: Ontario, Canada
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 2
C
#include <stdio.h>
void count(int start, int end);
int main(void) {
count(1, 10);
return 0;
}
void count(int start, int end) {
int x;
for(x = start; x <= end; x++)
printf("%d\n", x);
} --Jessehk
•
•
Join Date: May 2006
Location: Ontario, Canada
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 2
![]() |
•
•
•
•
•
•
•
•
DaniWeb Software Developers' Lounge Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
ajax asp blog browsing bt business business software creative design developer development devices erp systems experiment firefox howto illustrator india internet malware mcafee media microsoft mmorpg msdn news office online open-source photoshop print project management publishing rss search security software software selection spyware sql super technology evaluation tips toread vista warez web wiki windows
- Previous Thread: Viewing .cdr extension files
- Next Thread: Debuging



I never got around to really improving it.
Linear Mode