>>11
This is the Pythonic way: print ''.join(chr(n) for n in xrange(127))
Python's map returns a list while [elem] for [elem] in [iterable] returns a more efficient generator.
I prefer the C implementation (I don't know why OP called it "C/C++" except to troll I guess). I like the fact that you have to #include an I/O library. I don't like the fact that the other languages all just assume that I'm doing text-based I/O, whether I am or not.
>>17 #include an I/O library
One doesn't #include a library, one does #include header files declaring the library's functions and defining related macros, inline functions, or types.
Name:
Anonymous2011-08-08 14:27
>>16
no the Pythonic way is to import an alphabet printing function.
This document is written in XML using an NNTP-specific DTD. Custom
software is used to convert this to RFC 2629 [RFC2629] format, and
then the public "xml2rfc" package to further reduce this to text,
nroff source, and HTML.
No perl was used in producing this document.
Name:
Anonymous2011-08-08 16:00
program a;
{$mode objfpc}
var i: byte;
begin
for i in [0..127] do
write(chr(i));
readln;
end.
public class PrintChars {
public static void main(String[] args) {
Integer minimumBound = new Integer(0),
maximumBound = new Integer(128);
CharBuffer agile = CharBuffer.allocate(maximumBound.intValue());
for (int i = minimumBound.intValue();
i < maximumBound.intValue();
i = i + new Integer(1).intValue())
{
int codepoint = i;
int width = Character.charCount(codepoint);
if (width > 1) {
Integer integerCodepoint = new Integer(width);
String integerCodepointString = integerCodepoint.toString();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Codepoint ");
stringBuilder.append(integerCodepointString);
stringBuilder.append(" is too long for CharBuffer");
stringBuilder.ensureCapacity(stringBuilder.length());
stringBuilder.trimToSize();
String message = stringBuilder.toString();
IllegalArgumentException illegalArgumentException =
new IllegalArgumentException(message);
throw illegalArgumentException;
}
C99: #include <stdio.h>
int main(void) { for (char c = 0; c < 127; c++) putchar(c); }
Perl: my $x; #needlessly declare variable outside of loop
foreach $x (0..127)
{ #put brace on next line to give appearance of more code
print(chr($x));
}
print "\n"; #add a newline - one more line of code
exit 0; #redundantly specify default exit status