Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixes by decasm++
  • Loading branch information
lichtkind committed Jul 26, 2014
1 parent 8e84439 commit e3b2a65
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
38 changes: 19 additions & 19 deletions docs/tablet-2-basic-syntax.txt
Expand Up @@ -14,7 +14,7 @@ Please start your Perl 6 program with one of the following lines.
use v6.0;
v6;

or just start with a keyword like [**module**](appendix-a-index.html#module)
Or just start with a keyword like [**module**](appendix-a-index.html#module)
or [**class**](appendix-a-index.html#class). That marks your code as Perl 6
(in case the interpreter defaults to Perl 5) and makes it possible to mix
Perl 5 and 6 in one source file.
Expand Down Expand Up @@ -172,7 +172,7 @@ Any additional interpretation is added by [quoting adverbs](appendix-b-grouped.h
that follow the operator and start with a colon. Most of them have a short and a long name.

With few exceptions adverbs activate sorts of interpolation.
This means for instance that a [variable](tablet-3-variables.html.html) inside
This means for instance that a [variable](tablet-3-variables.html) inside
a quotation will be replaced with its content.
This happens of course at [*run time*](appendix-g-glossary.html#run-time).
Als [anonymous blocks](tablet-6-blocks.html) or
Expand All @@ -196,7 +196,7 @@ and their result gets inserted into the quote instead of the code.
# braces to interpolate arrays
Q :a /me@primes.de/;
# all developer names (values, not keys) separated by single
# spaces, [angle brackets](basic-syntax.html#quote-words) work too
# spaces, [angle brackets](#quote-words) work too
Q :h /%dev{}/;
Q :h /%dev[rakudo] %dev<niecza>/; # just 2 values
Q :h /%dev/; # literally '%dev', you need braces here too
Expand All @@ -207,7 +207,7 @@ and their result gets inserted into the quote instead of the code.
Q :h /Perl 6 Compiler: %dev.keys./; # no interpolation
# inserts report of that day, even inside Strings the correctness
# of arguments will be checked!
Q :f :a /Here it Tom with the weather: &fetch_report($day)./;
Q :f :a /Here is Tom with the weather: &fetch_report($day)./;
Q :f :a /fetch_report($day)/; # interpolates just $day
# literal string '&fetch_report', even if the subroutine takes
# no arguments
Expand Down Expand Up @@ -235,7 +235,7 @@ known as /escape sequences/. For example, `\\\\` translates to `\\`, while
`\\'` translates to a `'`. You can avoid all that extra typing by using
adverbs.

'Welcome in Larry\'s madhouse'
'Welcome to Larry\'s madhouse'
'\'\\'; # string contains: '\
q |\||; # string contains: |

Expand Down Expand Up @@ -270,7 +270,7 @@ any whitespace (\\s aka <ws>).
qw/.../; # like Perl 5's qw/.../
<...>

Q :quotewords /.../; # qw/.../ with quote protextion
Q :quotewords /.../; # qw/.../ with quote protection
Q :ww /.../; # :qq implied
<<>> # also have a unicode alias (chevron)

Expand Down Expand Up @@ -345,8 +345,8 @@ operator with the right adverb.
Code
----

The following 3 aliases quote code that will be run immediately (on
runtime) and replaced with the result.
The following 3 aliases quote code that will be run immediately (at runtime)
and replaced with the result.

Q :exec /.../;
Q :x /.../;
Expand All @@ -373,12 +373,11 @@ Number Literals

Unlike strings, numbers don't need
[quoting](#quoting). But if there is a non number
character in it, there will be an error. Chars of a number definition
are: (0-9,.,+,-,e,E,i,\_) including the [radix
prefixes](#radix-prefixes): (0b,0o,0d,0x) and the
prefix for [version numbering](#version-number)
character in it, there will be an error. As Characters of a number
are defined: (0-9,.,+,-,e,E,i,\_) including the [radix prefixes](#radix-prefixes):
(0b,0o,0d,0x) and the prefix for [version numbering](#version-number)
(v). The + can also act as an operator that converts a string
to numerical context, which means: take form left to right all digits
to numerical context, which means: take from left to right all digits
and interprate as a numeric literal. This will fail if the string
contains any number numeric digits.

Expand All @@ -400,7 +399,7 @@ Prefixes may be use to enter numbers in the most commonly used
radices.

0b binary - base 2, digits 0..1
0o ocatal - base 8, digits 0..7
0o octal - base 8, digits 0..7
0d decimal - base 10, digits 0..9
0x hexadecimal - base 16, digits 0..9,a..f (case insensitive)

Expand Down Expand Up @@ -445,7 +444,7 @@ with braces.
As always, [.perl](#perl) gives you an almost source
like code formatting which results here in 3/7. Adding **.nude** you
get (3/7), the nude source code. There are 2 different [immutable
value types](appendix-b-grouped.html#immutable-types) representing
value types](appendix-b-grouped.html#immutable-types) to represent
both rational number. FatRat has unlimited precision and Rat has just
enough to be evaled into a Real type. When you explicitly [type a
variable](tablet-3-variables.html#data-types) to one of them, the braces become
Expand Down Expand Up @@ -489,7 +488,7 @@ perl

The `.perl` method returns a string that arranges any set of values in
the same format, as it would be defined in source code (if possible).
It's a built in pretty printer similar to Perl 5s Data::Dumper that works
It's a built in pretty printer similar to Perl 5's Data::Dumper that works
with data of any nesting depth.

@a.perl # evals to: [1, 2, 3, 4, 5]
Expand All @@ -513,9 +512,10 @@ to convert its arguments to [*strings*](appendix-g-glossary.html#string).
fmt
---

Small brother of sprinf that works as a method of a variable. If thats
a pair or list it formats of course several values in the same way
with same syntax as sprinf.
Little brother of sprintf that works as a method of a variable.
If that's a pair or list it formats all values in the same way
with same syntax as sprintf.


$result = '5.123456789';
say $result.fmt('%.2f'); # "5.12\n"
Expand Down
46 changes: 23 additions & 23 deletions docs/tablet-3-variables.txt
@@ -1,6 +1,6 @@
% Perl 6 Tablet 3 - Variables

> "The most basic building blocks of a programming language are its
> "The most basic building blocks of a programming language are it's
> nouns, the chunks of data that get sucked in, pushed around, altered
> in various ways, and spat out to some new location." -- Allison
> Randal
Expand All @@ -14,7 +14,7 @@ Perl 6 (as Perl 5) knows 3 basic types of variables:
values) and [Hashes](#hash) (2 column table, with ID and
associated value pairs). They can be easily distinguished, because in
front of their name is a special character called
[sigil](appendix-b-grouped#sigils) (latin for sign). Its the $
[sigil](appendix-b-grouped#sigils) (latin for sign). It's the $
(similar to S) for Scalars, @ (like an a) for Arrays and a % (kv pair
icon) for a Hash. They are now invariant (not changing), which means
for instance, an array vaiable starts always with an @, even if you
Expand Down Expand Up @@ -68,7 +68,7 @@ item context, hence the `scalar` instruction from Perl 5 was renamed to
$pi = 3.14159_26535_89793; # the underscores just ease reading
$float = 6.02e-23; # floating number in scientific notation
$text = 'Welcome all!'; # single quoted string
# double quoted string, does eval $pi to its content
# double quoted string, does eval $pi to it's content
$text = " What is $pi?";
$text = q:to'EOT'; # heredoc string

Expand Down Expand Up @@ -140,7 +140,7 @@ prevent autoflattening.

@primes = (2,3,5,7,11,13,17,19,23); # an array gets filled like in Perl 5
@primes = 2,3,5,7,11,13,17,19,23 ; # same thing, since unlike P5 round braces just do group
@primes = <2 3 5 7 11 13 17 19 23>; # dito, <> is the new qw()
@primes = <2 3 5 7 11 13 17 19 23>; # ditto, <> is the new qw()
$primes = (2,3,5,7,11,13,17,19,23); # same array object just sits in $primes, $primes[0] is 2
$primes = item @primes; # same thing, more explicit
$primes = 2,; # just 2, first element of the Parcel
Expand All @@ -158,7 +158,7 @@ prevent autoflattening.
@primes # all values as list
@primes.values # same thing
@primes.keys # list of all indices
"@primes[]" # insert all values in a string, uses [] as distinction from mail adresses
"@primes[]" # insert all values in a string, uses [] to distinguish from mail adresses
$prime = @primes[0]; # get the first prime
$prime = @primes[*-1]; # get the last one
@some = @primes[2..5]; # get several
Expand All @@ -174,7 +174,7 @@ prevent autoflattening.
Some of the more important things you can do with lists. All the
methods can also used like ops in "elems @rray;"

? @rray; # boolean context, Bool::True if array has any value in it, even if its a 0
? @rray; # boolean context, Bool::True if array has any value in it, even if it's a 0
+ @rray; # numeric context, number of elements (like in Perl 5 scalar @a)
~ @rray; # string context, you get content of all cells, stringified and joined, same as "@primes[]"

Expand All @@ -186,20 +186,20 @@ methods can also used like ops in "elems @rray;"
@rray.shift; # remove the first value and return it
@rray.push; # add one value on the end
@rray.pop; # remove one value from the end and return it
@rray.splice($pos,$n);# remove on $pos $n values and replace them with values that follow that two parameter
@rray.delete(@ind); # delete all cell with indecies of @ind
@rray.exists(@ind); # Bool::True if all indecies of @ind have a value (can be 0 or '')
@rray.splice($pos,$n);# starting at $pos remove $n values and replace them with values that follow those two parameters
@rray.delete(@ind); # delete all cells with indices in @ind
@rray.exists(@ind); # Bool::True if all indices of @ind have a value (can be 0 or '')
@rray.pick([$n]); # return $n (default is 1) randomly selected values, without duplication
@rray.roll([$n]); # return $n (default is 1) randomly selected values, duplication possible (like roll dice)
@rray.reverse; # all elements in reversed order
# returns a list where $n times first item is taken to last
# position if $n is positive, if negative the other way around
@rray.rotate($n);

@rray.sort($coderef); # returns a sorted list by a userdefined criteria, default is alphanumerical sorting
@rray.sort($coderef); # returns a list sorted by a user-defined criteria, default is alphanumerical sorting
@rray.min; # numerical smallest value of that array
@rray.max; # numerical largest value of that array
$a,$b= @rray.minmax; # both at once, like in .sort . min or .max a sorting algorith can be provided
$a,$b= @rray.minmax; # both at once, like in .sort, .min, or .max, a sorting algorithm can be provided

@rray.map($coderef); # high oder map function, runs $coderef with every value as $_ and returns the list or results
@rray.classify($cr); # kind of map, but creates a hash, where keys are the results of $cr and values are from @rray
Expand All @@ -215,10 +215,10 @@ There is even a whole class of metaoperators that work upon lists.
Hash
----

is in Perl 6 an unordered list of Pairs. [A Pair](#pair)
In Perl 6 a Hash is an unordered list of Pairs. [A Pair](#pair)
is a single key `=>` value association and [appears in many
places](tablet-1-language-design.html#maximum_reusage) of the language syntax.
A hash allows lookup of values by key value using `{}` or `<>` syntax.
A hash allows lookup of values by key using `{}` or `<>` syntax.

%dev = 'pugs'=>'audreyt', 'pct'=>'pm', "STD"=>'larry';
%dev = :rakudo('jnthn'), :testsuite('moritz'); # adverb (pair) syntax works as well
Expand All @@ -240,7 +240,7 @@ A hash allows lookup of values by key value using `{}` or `<>` syntax.
%dev {'audrey'}; # error, spaces between varname and braces (postcircumfix operator) are no longer allowed
%dev\ {'allison'}; # works, quote the space
%dev .<dukeleto>; # error
%dev\ .{'patrick'}; # works too, "long dot style", because its its an object in truth
%dev\ .{'patrick'}; # works too, "long dot style", because it's an object in truth



Expand All @@ -255,7 +255,7 @@ A hash allows lookup of values by key value using `{}` or `<>` syntax.
@pairs = %dev; # list of all containing pairs
%dev.pairs # same thing in all context
%dev.elems # same as + %dev or + %dev.pairs
%dev.keys # returns the list with all keys
%dev.keys # returns a list of all keys
%dev.values # list of all values
%dev.kv # flat list with key1, value1, key 2 ...
%dev.invert # reverse all key => value relations
Expand Down Expand Up @@ -288,9 +288,9 @@ In contrast to [variable types](#variable-types)
(container types) every [value has a
type](appendix-b-grouped.html#value-types) too. These are
organized internally as classes or roles and can be categorized into 3
piles: the undefined, immutable and the mutable types.
piles: the undefined, immutable, and the mutable types.

You can assign one of these types to scalar, array or hash variables,
You can assign one of these types to scalar, array, or hash variables,
which enforces the contents to be that type.

my Int $a;
Expand Down Expand Up @@ -331,13 +331,13 @@ parameters, it is a mixture of a list and array.
||$cap # flatten into semicolon list (meant for variadic functions that take list of lists)


One important difference between a compound structure of lists and
hashes and a capture: while [assignments](#assignment)
with = the complete content of the named variables will be copied. But
One important difference between a capture and a compound structure of
lists and hashes: While [assignments](variables.html#assignment)
with = will copy the complete content of the named variables, this is
not so in the case of a capture. When I change $s in the last example,
the content of $cap changes too, because when parameters to a routine
are variables, they are also interpolated in the moment the routine is
called, not when its defined.
called, not when it's defined.



Expand Down Expand Up @@ -393,7 +393,7 @@ Assignment
As rightfully expected, assignments are done with the equal sign. But
unlike Perl 5 you always get a copy of the right side data assigned to
the left, no matter how nested the data structure was (lists of lists
eg). You never get in Perl 6 a reference with =. As the only exception
eg). You never get in Perl 6 a reference with =. The only exception
may be seen [captures](#capture).

my @original = [1,2],[3,4];
Expand All @@ -413,7 +413,7 @@ binding to get 2 variables that point to the same memory location.
$original ::= $mirror; # same thing, but done during compile time
$original = 3;
say $mirror; # prints 3
$original =:= $mirror # true, because their bound together
$original =:= $mirror # true, because they're bound together
$original === $mirror # also true, because content and type are equal


Expand Down

0 comments on commit e3b2a65

Please sign in to comment.