langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,11 @@
/*!
@function add
@abstract Adds two numbers
@discussion Use add to sum two numbers.
@param a an integer.
@param b another integer.
@return the sum of a and b
*/
int add(int a, int b) {
return a + b;
}

View file

@ -0,0 +1 @@
addhelp(funcName, "funcName(v, n): This is a description of the function named funcName.");

View file

@ -0,0 +1,11 @@
#= it's yellow
sub marine { ... }
say &marine.WHY; # "it's yellow"
#= a shaggy little thing
class Sheep {
#= not too scary
method roar { 'roar!' }
}
say Sheep.WHY; # "a shaggy little thing"
say Sheep.^find_method('roar').WHY; # "not too scary"

View file

@ -0,0 +1,35 @@
; This is a small demo-code to demonstrate PureBasics internal
; documentation system.
;- All Includes
; By starting the line with ;- marks that specific line as a special comment,
; and this will be included in the overview, while normal comments will not.
IncludeFile "MyLibs.pbi"
IncludeFile "Combustion_Data.pbi"
;-
;- Start of functions and Macros
;- Engeneering stuff
; A small function to calculate gas properties
Procedure.f CalcR( p.f, V.f, T.f)
ProcedureReturn p*V/T
EndProcedure
; Example of a Macro
; These are indicated by '+' in the overview
Macro HalfPI()
(#PI/2)
EndMacro
;-
;- - - - - - - - - - -
;- IO-Functions
Procedure Write_and_Close( File, Text$)
If IsFile(File)
WriteString(File,Text$)
CloseFile(file)
EndIf
EndProcedure

View file

@ -0,0 +1,66 @@
REBOL [
Title: "Documentation"
Date: 2009-12-14
Author: oofoe
URL: http://rosettacode.org/wiki/Documentation
Purpose: {To demonstrate documentation of REBOL pograms.}
]
; Notice the fields in the program header. The header is required for
; valid REBOL programs, although the fields don't have to be filled
; in. Standard fields are defined (see 'system/script/header'), but
; I can also define other fields as I like and they'll be available
; there.
; This is a comment. The semicolon can be inserted anywhere outside of
; a string and will escape to end of line. See the inline comments
; below.
; Functions can have a documentation string as the first part of the
; argument definition block. Each argument can specify what types it
; will accept as well as a description. All typing/documentation
; entries are optional. Notice that local variables can be documented
; as well.
sum: func [
"Add numbers in block."
data [block! list!] "List of numbers to add together."
/average "Calculate average instead of sum."
/local
i "Iteration variable."
x "Variable to hold results."
] [
x: 0 repeat i data [x: x + i]
either average [x / length? data][x] ; Functions return last result.
]
print [sum [1 2 3 4 5 6] crlf sum/average [7 8 9 10] crlf]
; The help message is constructed from the public information about
; the function. Internal variable information isn't shown.
help sum print ""
; The source command provides the source to any user functions,
; reconstructing the documentation strings if they're provided:
source sum print ""
; This is an object, describing a person, whose name is Bob.
bob: make object! [
name: "Bob Sorkopath"
age: 24
hi: func ["Say hello."][print "Hello!"]
]
; I can use the 'help' word to get a list of the fields of the object
help bob print ""
; If I want see the documentation or source for 'bob/hi', I have to
; get a little tricky to get it from the object's namespace:
x: get in bob 'hi help x print ""
probe get in bob 'hi

View file

@ -0,0 +1,15 @@
doc{
========
Function: foo
========
Stack
----
a1 a2 - b
Usage
-----
Adds a1 to a2 returning b.
}doc
: foo ( aa-b ) + ;

View file

@ -0,0 +1,2 @@
10 LET a=10: REM a is the number of apples
1000 DEF FN s(q)=q*q: REM s is a function that takes a single numeric parameter and returns its square

View file

@ -0,0 +1,7 @@
10 GOSUB 2000: REM call a subroutine to print the documentation
1999 STOP
2000 REM Print the documentation
2010 LPRINT "a is the number of apples"
2020 LPRINT "s is a function that takes a single numeric parameter and returns"
2030 LPRINT "its square"
2040 RETURN