Last active
February 3, 2016 07:29
-
-
Save mrpollo/0e530f8108c4748e8479 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string> | |
#include <stdint.h> | |
#include <unistd.h> // for abort | |
#include <string.h> // for strerror | |
#include <errno.h> | |
#include <stdlib.h> | |
#include <memory> | |
#include <string> | |
// from: http://stackoverflow.com/questions/2342162/stdstring-formatting-like-sprintf | |
template<typename ... Args> | |
std::string | |
string_format( const char* format, const Args ... args ) | |
{ | |
int32_t size = snprintf( nullptr, 0, format, args ... ); | |
if (size < 0) { | |
::fprintf(stderr, "snprintf error (%d): %s\n", size, strerror(errno)); | |
abort(); | |
} | |
size += 1; // Extra space for '\0' | |
std::unique_ptr<char[]> buf( new char[ size ] ); | |
snprintf( buf.get(), size, format, args ... ); | |
return std::string( buf.get(), buf.get() + size - 1 ); // We don't want the '\0' inside | |
} | |
int | |
main(int argc, char*argv[]) | |
{ | |
std::string objectname = ""; | |
for (uint8_t i=1; i<=100; i++) { | |
if (i != 1) { | |
objectname += ", "; | |
} | |
objectname += string_format("_%d", i); | |
::fprintf(stderr, "class Tuple%d{public Object %s;}\n", i, objectname.c_str()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i=1:100;println("class Tuple$i {public Object _$(join(0:i-1,",_"));}");end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local $" = ", "; foreach (0..100) { push @objects, "_${_}"; print "class Tuple$_\{public Object @objects;\}\n"; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0.upto(100){|i|puts "class Tuple#{i} {public Object _#{(0...i).to_a.join ',_'};}"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for i=1:100;println("class Tuple$i {public Object _$(join(0:i-1,",_"));}");end
#Julia