Forum: C++ Dec 18th, 2007 |
| Replies: 12 Views: 1,243 Boost.Format maybe? :)
http://www.boost.org/libs/format/index.html
#include <iostream>
#include <boost/format.hpp>
int main() {
int age = 17; |
Forum: Ruby Oct 15th, 2007 |
| Replies: 1 Views: 4,232 I can't say that this is "correct', but this is the way I'd approach the problem. :)
#!/usr/bin/ruby
def yes_no(question)
print question
if gets.chomp =~ /^[yY]/
... |
Forum: Python Oct 13th, 2007 |
| Replies: 3 Views: 1,695 In your definition for squareEach, you are saying that it takes a list of numbers as a parameter. When you call the function, you are not giving it any parameters. The correct definition in this case... |
Forum: C++ Jul 19th, 2007 |
| Replies: 7 Views: 11,409 I don't exactly understand the question, but have you considered using something like boost::tokenizer?
http://boost.org/libs/tokenizer/index.html |
Forum: C++ Jul 18th, 2007 |
| Replies: 8 Views: 16,343 Hash tables (called unordered_map) are part of tr1, which is mostly being implemented for the next version of C++.
GCC has implemented most of tr1 and it happens to include an implementation of... |
Forum: IT Professionals' Lounge Sep 4th, 2006 |
| Replies: 81 Views: 15,896 That we can. On the forum where I stole this idea, we got to 500. :)
#include <iostream>
template <int n>
class Counter {
public:
Counter() {
Counter<n - 1> count; |
Forum: IT Professionals' Lounge Aug 4th, 2006 |
| Replies: 81 Views: 15,896 I just started teaching myself O'Caml :)
let rec range s f =
if s > f then []
else s :: range (s + 1) f ;;
let count s f =
List.iter (fun i -> Printf.printf "%d " i) (range s... |
Forum: Ruby Jun 16th, 2006 |
| Replies: 0 Views: 6,867 This is a simple, but complete (pseudo) random password generator.
Examples of usage:
$ ruby pgen.rb
soovmuvytv
$ ruby pgen.rb --length=20
bynnugipyeeghdbihcdn
$ ruby pgen.rb --length=20... |
Forum: C++ May 14th, 2006 |
| Replies: 6 Views: 2,973 A for() loop is best used when you know (either based on a variable's value, or a set number) how many times a loop should run. For example, if I wanted to have a message printed exactly 5 times, I... |
Forum: C++ May 14th, 2006 |
| Replies: 4 Views: 10,686 I know this works, but I don't know if it is a best practise.
#include <iostream>
#include <string>
void changeFirstLetter(char *str) {
*str = 'J';
} |
Forum: IT Professionals' Lounge May 13th, 2006 |
| Replies: 81 Views: 15,896 This is so unnecessary it's not even funny. At least I had fun writing it. ;)
Ruby
((10..90).reject { |x| not (x % 10).zero? }.collect { |x| x.to_s.reverse.to_i } << 10 ).each { |x| p x } |
Forum: IT Professionals' Lounge May 13th, 2006 |
| Replies: 81 Views: 15,896 I'm sure somebody who knows what they're talking about could make a much better implementation (or find improvements for mine ;) ), but here is a linked list in C.
#include <stdio.h>
#include... |
Forum: IT Professionals' Lounge May 10th, 2006 |
| Replies: 81 Views: 15,896 Python
for x in range(10):
print x + 1 |
Forum: IT Professionals' Lounge May 9th, 2006 |
| Replies: 81 Views: 15,896 C
#include <stdio.h>
void count(int start, int end);
int main(void) {
count(1, 10); |
Forum: IT Professionals' Lounge May 9th, 2006 |
| Replies: 81 Views: 15,896 Of course not. ;)
Bah, I wanted to be the first to use Ruby. Anyways...
Ruby
puts *(1..10) |
Forum: IT Professionals' Lounge May 9th, 2006 |
| Replies: 81 Views: 15,896 C++
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
int main() {
std::vector<int> numbs(0); |
Forum: IT Professionals' Lounge May 8th, 2006 |
| Replies: 81 Views: 15,896 Scheme
(define range
(lambda (s e)
(cond ((< s e) (cons s
(range (+ s 1) e)))
((= s e) (list s))
(else "Invalid function call")))) |
Forum: IT Professionals' Lounge May 8th, 2006 |
| Replies: 81 Views: 15,896 *Hopefull this hasn't been done already*
Write a program that when run, will print out the numbers 1 through 10. The program can be in any language, and can be as complicated or simple as you... |
Forum: Community Introductions May 7th, 2006 |
| Replies: 0 Views: 665 Hello all.
I was just browing some websites and thought I'd join. I program as a hobby (Some C, intermediate C++, and I'm improving my Python and Ruby), and I'm sure I'll be asking more questions... |