First commit of partial RosettaCode contents.

Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
Ingy döt Net 2013-04-08 13:02:41 -07:00
commit 1e05ecd7ee
781 changed files with 9080 additions and 0 deletions

View file

@ -0,0 +1,4 @@
Demonstrate all ways to include text in a language source file which is completely ignored by the compiler or interpreter.
'''See Also:'''<br>
* [http://xkcd.com/156 xkcd] (Humor: hand gesture denoting <code>//</code> for "commenting out" people).

2
Task/Comments/1META.yaml Normal file
View file

@ -0,0 +1,2 @@
---
note: Basic language learning

View file

@ -0,0 +1 @@
`Comments in 4th Dimension begin with the accent character and extend to the end of the line.

View file

@ -0,0 +1,3 @@
BEGIN { # this code does something
# do something
}

View file

@ -0,0 +1,6 @@
&;read a number;2+;add two;.@;display result and exit;
^- inline comments -^ <-^- other comments
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;completely isolated comment block for the paranoid;
;(almost - you can still skip into it.) ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -0,0 +1,2 @@
& read a number 2+ add two .@ display result and exit
^- inline comments -^ <-^- other comments

View file

@ -0,0 +1,2 @@
struct charisma {};
void f(char/* comment */isma) {}

View file

@ -0,0 +1 @@
/* some comment /* trying to nest some other comment */ inside */

View file

@ -0,0 +1,3 @@
#if 0
While technically not a comment, this is also ignored by the compiler
#endif

View file

@ -0,0 +1,7 @@
#ifdef UNDEFINED
This is not compiled.
#if 0
Nor is this.
#endif
And this still is not compiled.
#endif

View file

@ -0,0 +1,3 @@
#if 0
This isn't valid.
#endif

View file

@ -0,0 +1 @@
// C++ single-line comments were adopted in the C99 standard.

View file

@ -0,0 +1,4 @@
/* This is a comment. */
/* So is this
multiline comment.
*/

View file

@ -0,0 +1 @@
(comment (println (foo)) "bar" :baz 123 (System/exit 0)) ;; does nothing, returns nil

View file

@ -0,0 +1,2 @@
(+ 1 (comment "foo") 3) ;; Throws an exception, because it tries to add nil to an integer
(+ 1 #_"foo" 3) ;; Returns 4

View file

@ -0,0 +1,3 @@
;; This is a comment
(defn foo []
123) ; also a comment

View file

@ -0,0 +1,5 @@
# one line comment
### multi
line
comment ###

View file

@ -0,0 +1 @@
% Erlang comments begin with "%" and extend to the end of the line.

View file

@ -0,0 +1 @@
: myword ( a b -- c ) ...

View file

@ -0,0 +1,2 @@
: add'em ( a b -- a+b ) + ;
: strlen ( addr -- len ) count nip ;

View file

@ -0,0 +1,11 @@
\s skips all remaining text in the file
(( skips until the next double-paren,
stretching across multiple lines ))
comment:
Ignore all text in this section
comment;
doc
Another comment block
enddoc
/* C-style comment */
(* Pascal-style comment *)

View file

@ -0,0 +1,2 @@
\ The backslash skips everything else on the line
( The left paren skips everything up to the next right paren on the same line)

View file

@ -0,0 +1,2 @@
C If compiled in debugging mode, print the current value of I
D PRINT *, I

View file

@ -0,0 +1 @@
real :: a = 0.0 ! initialize A to be zero

View file

@ -0,0 +1,7 @@
?? if (.false.) then
do while (oh_no)
a = bad_news()
b = big_mistake()
c = gigo()
end do
?? end if

View file

@ -0,0 +1,2 @@
C This would be some kind of comment
C Usually one would avoid columns 2-6 even in a comment.

View file

@ -0,0 +1,5 @@
// this is a single line comment
/* this is
a multi-line
block comment.
/* It does not nest */

View file

@ -0,0 +1,15 @@
i code = True -- I am a comment.
{- I am also
a comment. {-comments can be nested-}
let u x = x x (this code not compiled)
Are you? -}
-- |This is a Haddock documentation comment for the following code
i code = True
-- ^This is a Haddock documentation comment for the preceding code
{-|
This is a Haddock documentation block comment
-}
i code = True

View file

@ -0,0 +1,5 @@
/*
* This is
* a multiple
* line comment.
*/

View file

@ -0,0 +1 @@
// This is a comment

View file

@ -0,0 +1 @@
/** This is a Javadoc comment */

View file

@ -0,0 +1,5 @@
/**
* This is
* a multiple
* line Javadoc comment
*/

View file

@ -0,0 +1 @@
/* This is a comment */

View file

@ -0,0 +1,7 @@
\newcommand{\firstpart}{understand}
\newcommand{\secondpart}{able}
\newcommand{\complete}{%
\firstpart%
\secondpart}
\complete

View file

@ -0,0 +1 @@
% This is a comment

View file

@ -0,0 +1,2 @@
--[====[ A multi-line comment that can contain [[ many square brackets ]]
]====]

View file

@ -0,0 +1,4 @@
-- A single line comment
--[[A multi-line
comment --]]

View file

@ -0,0 +1,2 @@
$var = 1; # this is the comment part
$var = 1; // this is the comment part

View file

@ -0,0 +1,4 @@
/*
Here are my comments
this is multi-line
*/

View file

@ -0,0 +1,4 @@
/**
* phpdoc Comments
* @todo this is a todo stub
*/

View file

@ -0,0 +1,2 @@
# this is commented
// this is commented

View file

@ -0,0 +1 @@
my $var = 1; # this is the comment part

View file

@ -0,0 +1,6 @@
=pod
Here are my comments
this is multi-line
=cut

View file

@ -0,0 +1,4 @@
=head1
=head4
=over 4
=Any Old String

View file

@ -0,0 +1 @@
# this is commented

View file

@ -0,0 +1,12 @@
# The rest of the line is ignored
#{
This is a
multiline comment
}#
NIL
Immediately stop reading this file. Because all text in the input file following
a top-level 'NIL' is ignored.
This is typically used conditionally, with a read-macro expression like
`*Dbg
so that this text is only read if in debugging mode.

View file

@ -0,0 +1,17 @@
#!/usr/bin/env python
# Example of using doc strings
"""My Doc-string example"""
class Foo:
'''Some documentation for the Foo class'''
def __init__(self):
"Foo's initialization method's documentation"
def bar():
"""documentation for the bar function"""
if __name__ == "__main__":
print (__doc__)
print (Foo.__doc__)
print (Foo.__init__.__doc__)
print (bar.__doc__)

View file

@ -0,0 +1,9 @@
"""Un-assigned strings in triple-quotes might be used
as multi-line comments
"""
'''
"triple quoted strings" can be delimited by either 'single' or "double" quote marks; and they can contain mixtures
of other quote marks without any need to \escape\ them using any special characters. They also may span multiple
lines without special escape characters.
'''

View file

@ -0,0 +1,3 @@
-- A REXX line comment
say "something" -- another line comment

View file

@ -0,0 +1,42 @@
/*REXX program to demonstrate various uses and types of comments. */
/* everything between a "climbstar" and a "starclimb" (exclusive of literals) is
a comment.
climbstar = /* [slash-asterisk]
starclimb = */ [asterisk-slash]
/* this is a nested comment, by gum! */
/*so is this*/
Also, REXX comments can span multiple records.
There can be no intervening character between the slash and asterisk (or
the asterisk and slash). These two joined characters cannot be separated
via a continued line, as in the manner of:
say 'If I were two─faced,' ,
'would I be wearing this one?' ,
' --- Abraham Lincoln'
Here come's the thingy that ends this REXX comment. ───┐
│
│
↓
*/
hour = 12 /*high noon */
midnight = 00 /*first hour of the day */
suits = 1234 /*card suits: ♥ ♦ ♣ ♠ */
hutchHdr = '/*'
hutchEnd = "*/"
/* the previous two "hutch" assignments aren't
the start nor the end of a REXX comment. */
x=1000000 ** /*¡big power!*/ 1000
/*not a real good place for a comment (above),
but essentially, a REXX comment can be
anywhere whitespace is allowed. */

View file

@ -0,0 +1,5 @@
x = "code" # I am a comment
=begin hello
I a POD documentation comment like Perl
=end puts "code"

View file

@ -0,0 +1,4 @@
// A single line comment
/* A multi-line
comment */

View file

@ -0,0 +1,4 @@
set aList {foo}
lappend aList # bar
puts $aList ;# ==> prints "foo # bar"
puts [llength $aList] ;# ==> 3

View file

@ -0,0 +1,3 @@
if 0 {
Comments...
}

View file

@ -0,0 +1,3 @@
# comment on a line by itself. The next is a command by itself:
set var1 $value1
set var2 $value2 ; # comment that follows a line of code