Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,21 @@
256 buffer: first-name
256 buffer: last-name
: is ( a "name" -- ) parse-name rot place ;
: greet ( -- )
cr ." Hello, " first-name count type space last-name count type ." !" ;
first-name is Bob last-name is Hall greet
require mini-oof2.fs
require string.fs
object class
field: given-name
field: surname
end-class Person
: hiya ( -- )
cr ." Hiya, " given-name $. space surname $. ." !" ;
Person new >o s" Bob" given-name $! s" Hall" surname $! hiya o>

View file

@ -1,12 +1,12 @@
sub funkshun
{my %h = @_;
# Print every argument and its value.
sub funkshun {
my %h = @_;
# Print every argument and its value.
print qq(Argument "$_" has value "$h{$_}".\n)
foreach sort keys %h;
# If a 'verbosity' argument was passed in, print its value,
# whatever that value may be.
exists $h{verbosity}
and print "Verbosity specified as $h{verbosity}.\n";
# Say that safe mode is on if 'safe' is set to a true value.
# Otherwise, say that it's off.
print "Safe mode ", ($h{safe} ? 'on' : 'off'), ".\n";}
# If a 'verbosity' argument was passed in, print its value
# whatever that value may be.
print "Verbosity specified as $h{verbosity}.\n" if exists $h{verbosity};
# Say that safe mode is on if 'safe' is set to a true value.
# Otherwise, say that it's off.
print "Safe mode ", ($h{safe} ? 'on' : 'off'), ".\n";
}

View file

@ -1,3 +1,7 @@
funkshun
verbosity => 3, password => 'foobie blech',
extra_lives => 3, '42' => 'answer', password => 'joshua';
funkshun(
verbosity => 3,
password => 'foobie blech',
extra_lives => 3,
'42' => 'answer',
password => 'joshua'
);

View file

@ -0,0 +1,37 @@
sub event
{
my ($params_ref, $name) = @_;
my %params = %$params_ref;
my @known_params = qw(attendees event food time);
printf "%s called event() with the following named parameters:\n",
$name // 'Anonymous';
say sort map {
sprintf "%s: %s\n",
ucfirst $_,
ref $params{$_} eq ref []
? join ', ', @{ $params{$_} }
: $params{$_};
} grep exists $params{$_}, @known_params;
delete $params{$_} foreach @known_params;
say "But I didn't recognize these ones:";
while (my ($key, $val) = each %params)
{
say "$key: $val";
}
}
event(
{ # Curly braces with no label (e.g. 'sub' before it)
# create a reference to an anonymous hash
attendees => ['Bob', 'Betty', 'George', 'Bertha'],
event => 'birthday',
foo => 'bar',
food => 'cake',
frogblast => 'vent core',
time => 3,
},
"Joe Schmoe"
);

View file

@ -0,0 +1,21 @@
/* REXX ---------------------------------------------------------------
* 01.07.2014 Walter Pachl
* Argument values must not start with 'arg'
*--------------------------------------------------------------------*/
x=f(2,3)
Say x
Say ''
y=f('arg2='3,'arg1='2)
Say y
Exit
f: Procedure
Parse Arg p1,p2
Do i=1 to arg()
If left(arg(i),3)='arg' Then
Parse Value arg(i) With 'arg' j '=' p.j
Else p.i=arg(i)
End
Do i=1 To arg()
Say 'p.'i'='p.i
End
Return p.1**p.2