Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
from: http://rosettacode.org/wiki/Special_characters
note: Basic language learning

View file

@ -0,0 +1,12 @@
Special characters are symbols (single characters or sequences of characters) that have a "special" built-in meaning in the language and typically cannot be used in identifiers.
Escape sequences are methods that the language uses to remove the special meaning from the symbol, enabling it to be used as a normal character, or sequence of characters when this can be done.
;Task:
List the special characters and show escape sequences in the language.
{{Template:Strings}}
<br><br>

View file

@ -0,0 +1,2 @@
LDA #''' ;is likely to confuse the assembler, and is just hard to read.
LDA #$27 ;gets the same result and isn't ambiguous.

View file

@ -0,0 +1,2 @@
MOVE.B #''',D0 ;is likely to cause a parsing error when assembling.
MOVE.B #$27,D0 ;same result but works every time.

View file

@ -0,0 +1,2 @@
ascii_apostrophe equ $27
MOVE.B #ascii_apostrophe,D0

View file

@ -0,0 +1,5 @@
printf(($"flip:"g"!"l$,flip));
printf(($"flop:"g"!"l$,flop));
printf(($"blank:"g"!"l$,blank));
printf(($"error char:"g"!"l$,error char));
printf(($"null character:"g"!"l$,null character))

View file

@ -0,0 +1,4 @@
print(("new page:",new page));
print(("new line:",new line));
print(("space:",space));
print(("backspace:",backspace))

View file

@ -0,0 +1,6 @@
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
begin
Put ("Quote """ & ''' & """" & Character'Val (10));
end Test;

View file

@ -0,0 +1,6 @@
with Ada.Wide_Wide_Text_IO; use Ada.Wide_Wide_Text_IO;
procedure Test is
begin
Put ("Unicode """ & ''' & """" & Wide_Wide_Character'Val (10));
end Test;

View file

@ -0,0 +1,2 @@
std::cout << "Tür\n";
std::cout << "T\u00FC\n";

View file

@ -0,0 +1,2 @@
extern int Tür; // if the compiler allows literal ü
extern int T\u00FCr; // should in theory work everywhere

View file

@ -0,0 +1,2 @@
int const\
ant; // defines a variable of type int named constant, not a variable of type int const named ant

View file

@ -0,0 +1,2 @@
char const str = "a string literal";
char c = 'x'; // a character literal

View file

@ -0,0 +1 @@
#include <iostream>

View file

@ -0,0 +1,5 @@
#define STR(x) #x
int main()
{
std::cout << STR(Hello world) << std::endl; // STR(Hello world) expands to "Hello world"
}

View file

@ -0,0 +1,2 @@
#define THE(x) the_ ## x
int THE(answer) = 42; // THE(answer) expands to the_answer

View file

@ -0,0 +1,3 @@
? println(`1 + 1$\n= ${1 + 1}`)
1 + 1
= 2

View file

@ -0,0 +1,4 @@
10 \ single cell number
-10 \ negative single cell number
10. \ double cell number
10e \ floating-point number

View file

@ -0,0 +1,3 @@
#10 \ decimal
$10 \ hex
%10 \ binary

View file

@ -0,0 +1,2 @@
-- comment here until end of line
{- comment here -}

View file

@ -0,0 +1,2 @@
! # $ % & * + - . / < = > ? @ \ ^ | - ~ :
: as first character denotes constructor

View file

@ -0,0 +1 @@
.. : :: = \ | <- -> @ ~ => _

View file

@ -0,0 +1 @@
`identifier` (to use as infix operator)

View file

@ -0,0 +1,2 @@
'.'
\ escapes

View file

@ -0,0 +1,2 @@
"..."
\ escapes

View file

@ -0,0 +1,7 @@
\a alert
\b backspace
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab

View file

@ -0,0 +1,5 @@
( ) (grouping)
( , ) (tuple type/tuple constructor)
{ ; } (grouping inside let, where, do, case without layout)
[ , ] (list type/list constructor)
[ | ] (list comprehension)

View file

@ -0,0 +1,4 @@
Upper case (identifiers)
Lower case (identifiers)
Digits (numbers)
Symbol/punctuation (operators)

View file

@ -0,0 +1,6 @@
'' NB. empty string
'''' NB. one quote character
'
'''''' NB. two quote characters
''

View file

@ -0,0 +1 @@
'For example, this is a character literal'

View file

@ -0,0 +1,3 @@
1
1 0 1 0 1 0 1
_3.14159e6

View file

@ -0,0 +1,2 @@
3l1t3
|ill-formed number

View file

@ -0,0 +1 @@
example=: ARGV NB. example and ARGV are user definable words

View file

@ -0,0 +1 @@
+/ .* NB. + / . and * are all meaningful tokens in J

View file

@ -0,0 +1,4 @@
& | ^ ~ //bitwise AND, OR, XOR, and NOT
>> << //bitwise arithmetic shift
>>> //bitwise logical shift
+ - * / = % //+ can be used for String concatenation)

View file

@ -0,0 +1,3 @@
x = x + 2 is the same as x += 2
++ -- //increment and decrement--before a variable for pre (++x), after for post(x++)
== < > != <= >= //comparison

View file

@ -0,0 +1,3 @@
! //NOT
&& || //short-circuit AND, OR
^ & | //long-circuit XOR, AND, OR

View file

@ -0,0 +1,9 @@
{ } //scope
( ) //for functions
; //statement terminator
[ ] //array index
" //string literal
' //character literal
? : //ternary operator
// //comment prefix (can be escaped by \u unicode escape sequence see below)
/* */ //comment enclosures (can be escaped by \u unicode escape sequence see below)

View file

@ -0,0 +1,10 @@
\b //Backspace
\n //Line Feed
\r //Carriage Return
\f //Form Feed
\t //Tab
\0 //Null) Note. This is actually a OCTAL escape but handy nonetheless
\' //Single Quote
\" //Double Quote
\\ //Backslash
\DDD //Octal Escape Sequence, D is a number between 0 and 7; can only express characters from 0 to 255 (i.e. \0 to \377)

View file

@ -0,0 +1 @@
\uHHHH //Unicode Escape Sequence, H is any hexadecimal digit between 0 and 9 and between A and F

View file

@ -0,0 +1 @@
// hello \u000A this looks like a comment

View file

@ -0,0 +1 @@
"hello \u0022 is this a string?"

View file

@ -0,0 +1,3 @@
/*
* c:\unix\home\
*/

View file

@ -0,0 +1 @@
^[a-zA-Z_][a-zA-Z_0-9]*$

View file

@ -0,0 +1,4 @@
\documentclass{minimal}
\begin{document}
5\% of \$10
\end{document}

View file

@ -0,0 +1,21 @@
# defined local ie. #mylocal will fail if not defined
$ defined variable ie. $myvar will fail if not defined
= assignment
:= assign as return assigned value
? ternary conditional true ? this
| ternary else false ? this | that
|| or
&& and
! negative operator
{ open capture
} close capture
=> specify givenblock / capture
-> invoke method: mytype->mymethod
& retarget: mytype->mymethod& // returns mytype
^ autocollect from capture: {^ 'this will be outputted' ^}
:: tag prefix, ie. ::mytype->gettype // returns myype
:: type constraint, ie. define mymethod(p::integer) => #i * 2
\ escape method: ie. \mymethod->invoke(2)
// comment
/* open comment
*/ close comment

View file

@ -0,0 +1,3 @@
str = "Hello " & QUOTE & "world!" & QUOTE
put str
-- "Hello "world!""

View file

@ -0,0 +1,6 @@
VRAMBASE equ 0xA1000008
VRAMSIZE equ 0x12C00
SCREENWIDTH equ 320
la $t0,VRAMBASE+SCREENWIDTH ;skip the first row of pixels
li $t1,VRAMSIZE/2 ;we're going to fill half the screen

View file

@ -0,0 +1,5 @@
li $t0,0x27 ;trying to use li $t0,''' may confuse the assembler.
MyString:
.byte "Hello World",13,10,0 ;13 = carriage return, 10 = linefeed, 0 = null terminator
.align 4

View file

@ -0,0 +1,12 @@
Markup :
() Sequence
{} List
" String
\ Escape for following character
(* *) Comment block
base^^number`s
` Context
[[]] Indexed reference
Within expression:
\ At end of line: Continue on next line, skipping white space

View file

@ -0,0 +1 @@
var f = open(r"C:\texts\text.txt") # a raw string, so ``\t`` is no tab

View file

@ -0,0 +1 @@
r"a""b"

View file

@ -0,0 +1 @@
a"b

View file

@ -0,0 +1,7 @@
\b //Backspace
\n //Line Feed
\r //Carriage Return
\t //Tab
\0 //Null
\' //Single Quote
\" //Double Q

View file

@ -0,0 +1 @@
\uHHHH //Unicode Escape Sequence, H is any hexadecimal digit between 0 and 9 and between A and F

View file

@ -0,0 +1,3 @@
(print #\|) (print #\#)
; ==> 124
; ==> 35

View file

@ -0,0 +1,7 @@
(define |I'm the ,`stra[]ge symbol :))| 123)
(print (put #empty '|I'm the ,`stra[]ge symbol :))| 444))
; ==> #ff((|I'm the ,`stra[]ge symbol :))| . 444))
(print (+ |I'm the ,`stra[]ge symbol :))| 17))
; ==> 140

View file

@ -0,0 +1 @@
is square(9)

View file

@ -0,0 +1 @@
issquare(9)

View file

@ -0,0 +1 @@
iss qua re(9)

View file

@ -0,0 +1,2 @@
'John''s pen' which is stored as <<John's pen>>
"He said ""Go!"" and opened the door" which is stored as <<He said "Go!" and opened the door>>

View file

@ -0,0 +1,2 @@
a=1 ; The ';' indicates that a comment starts
b=2*a: a=b*33 ; b will now be 2, and a=66

View file

@ -0,0 +1,5 @@
if a¬==b then say 'not equal'
if a ¬== b then say 'not equal'
if a ¬ = = b then say 'not equal'
if a ¬ ,
= = b then say 'not equal'

View file

@ -0,0 +1 @@
jjj = "Quote the Raven, ""Nevermore"""

View file

@ -0,0 +1,3 @@
lf = '000001010'b /* (ASCII) */
cr = "1101"B /* (ASCII) */
greeting = '100100001100101011011000110110001101111'b /* (ASCII) Hello */

View file

@ -0,0 +1,5 @@
lf = '0A'x /* (ASCII) */
lf = 'a'x /*same as above. */
lf = "a"X /*same as above. */
cr = '0D'x /* (ASCII) */
greeting = '48656C6C6F'x /* (ASCII) Hello */

View file

@ -0,0 +1 @@
something=12 -- an assignment, what else

View file

@ -0,0 +1 @@
something=--12

View file

@ -0,0 +1,5 @@
x='--12 ++12 -12.000 +12 12 12. 012 0012 0012.00 1.2E1 1.2e+1 --12e-00 120e-1 ++12 ++12. 0--12 00--12 --12'
do j=1 for words(x)
interpret 'something=' word(x,j)
say 'j=' j ' x=' x ' something='something
end

View file

@ -0,0 +1,4 @@
say 'enter an expression:'
parse pull x
interpret 'expression=' x
say 'expression=' expression

View file

@ -0,0 +1 @@
x=5; y=6;z=y**2; say x y z

View file

@ -0,0 +1,2 @@
say 'The sum of the first three numbers in the file "INSTANCE.INPUTS" is',
a b c ' and the total of all three is' grandTotal

View file

@ -0,0 +1,2 @@
say 'The sums of the first three numbers in the file "INSTANCE.INPUTS" is', /*tell sums.*/
a b c ' and the total of all three is' grandTotal

View file

@ -0,0 +1 @@
If a/=b Then Say 'a is not equal to b'

View file

@ -0,0 +1,3 @@
secondChar = substr(xxx, 2, 1)
thirdChar = substr(xxx,3,1)
pruned = strip(zebra, 'Trailing', ".") /*remove trailing period(s).*/

View file

@ -0,0 +1,3 @@
y = (a+b)/(c-d)
z = ((y-2)/(y+2)) / ((a**2 * b**2)* abs(j))
p = 2**(2**3)

View file

@ -0,0 +1,3 @@
tn = time()
tc = time('C')
x = strip(y,,'+')

View file

@ -0,0 +1 @@
a = 'ready, set, go!'

View file

@ -0,0 +1 @@
a = "ready, set, go!"

View file

@ -0,0 +1,2 @@
nuttin =''
nothing=""

View file

@ -0,0 +1 @@
yyy = 'John''s pen'

View file

@ -0,0 +1 @@
yyy = "John's pen"

View file

@ -0,0 +1 @@
val n = 1 + 2

View file

@ -0,0 +1,20 @@
{...} ;# group in one word, without substituting content; nests
"..." ;# group in one word, with substituting content
[...] ;# evaluate content as script, then substitute with its result; nests
$foo ;# substitute with content of variable foo
$bar(foo) ;# substitute with content of element 'foo' of array 'bar'
\a ;# audible alert (bell)
\b ;# backspace
\f ;# form feed
\n ;# newline
\r ;# carriage return
\t ;# Tab
\v ;# vertical tab
\\ ;# backslash
\ooo ;# the Unicode with octal value 'ooo'
\xhh ;# the character with hexadecimal value 'hh'
\uhhhh ;# the Unicode with hexadecimal value 'hhhh'
# ;# if first character of a word expected to be a command, begin comment
;# (extends till end of line)
{*} ;# if first characters of a word, interpret as list of words to substitute,
;# not single word (introduced with Tcl 8.5)

View file

@ -0,0 +1,17 @@
// escape codes
windows_newline := '\r\n' // escape special characters like in C
assert windows_newline.len == 2
// arbitrary bytes can be directly specified using `\x##`
// a hex digit aardvark_str := '\x61ardvark' assert aardvark_str == 'aardvark'
assert '\xc0'[0] == u8(0xc0)
// or using octal escape `\###` notation where `#` is an octal digit
aardvark_str2 := '\141ardvark'
assert aardvark_str2 == 'aardvark'
// Unicode can be specified directly as `\u####` where # is a hex digit
// and will be converted internally to its UTF-8 representation
star_str := '\u2605' //
assert star_str == '★'
assert star_str == '\xe2\x98\x85' // UTF-8 can be specified this way too.