## dist_zef-lizmat-List-MoreUtils.md
## Chunk 2 of 2
 @list  = <alpha beta cicero delta>;
my @found = bsearch { $_ cmp "cicero" }, @list;   # ("cicero",)
my @found = bsearch { $_ cmp "effort" }, @list;   # ()

my @list  = <alpha beta cicero delta>;
my $found = bsearch Scalar, { $_ cmp "cicero" }, @list;   # True
my $found = bsearch Scalar, { $_ cmp "effort" }, @list;   # False

```

### bsearchidx BLOCK, LIST

### bsearch\_index BLOCK, LIST

Performs a binary search on LIST which must be a sorted list of values. BLOCK receives each element in turn and must return a negative value if the element is smaller, a positive value if it is bigger and zero if it matches.

Returns the index of found element, otherwise `-1`.

```
my @list  = <alpha beta cicero delta>;
my $found = bsearchidx { $_ cmp "cicero" }, @list;   # 2
my $found = bsearchidx { $_ cmp "effort" }, @list;   # -1

```

`bsearch_index` is an alias for `bsearchidx`.

### lower\_bound BLOCK, LIST

Returns the index of the first element in LIST which does not compare *less than val*. Technically it's the first element in LIST which does not return a value below zero when passed to BLOCK.

```
my @ids = 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6;
my $lb = lower_bound { $_ <=> 2 }, @ids; # 1
my $lb = lower_bound { $_ <=> 4 }, @ids; # 9

```

### upper\_bound BLOCK, LIST

Returns the index of the first element in LIST which does not compare *greater than val*. Technically it's the first element in LIST which does not return a value below or equal to zero when passed to BLOCK.

```
my @ids = 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6;
my $ub = upper_bound { $_ <=> 2 }, @ids; # 3
my $ub = upper_bound { $_ <=> 4 }, @ids; # 13

```

### equal\_range BLOCK, LIST

Returns a list of indices containing the `lower_bound` and the `upper_bound` of given BLOCK and LIST.

```
my @ids = 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6;
my $er = equal_range { $_ <=> 2 }, @ids; # (1,3)
my $er = equal_range { $_ <=> 4 }, @ids; # (9,13)

```

## Operations on sorted Lists

### binsert BLOCK, ITEM, LIST

### bsearch\_insert BLOCK, ITEM, LIST

Performs a binary search on LIST which must be a sorted list of values. BLOCK must return a negative value if the current element (passed as a parameter to the BLOCK) is smaller, a positive value if it is bigger and zero if it matches.

ITEM is inserted at the index where the ITEM should be placed (based on above search). That means, it's inserted before the next bigger element.

```
my @l = 2,3,5,7;
binsert { $_ <=> 4 },  4, @l; # @l = (2,3,4,5,7)
binsert { $_ <=> 6 }, 42, @l; # @l = (2,3,4,5,42,7)

```

You take care that the inserted element matches the compare result.

`bsearch_insert` is an alias for `binsert`.

### bremove BLOCK, LIST

### bsearch\_remove BLOCK, LIST

Performs a binary search on LIST which must be a sorted list of values. BLOCK must return a negative value if the current element (passed as a parameter to the BLOCK) is smaller, a positive value if it is bigger and zero if it matches.

The item at the found position is removed and returned.

```
my @l = 2,3,4,5,7;
bremove { $_ <=> 4 }, @l; # @l = (2,3,5,7);

```

`bsearch_remove` is an alias for `bremove`.

## Counting and calculation

### true BLOCK, LIST

Counts the number of elements in LIST for which the criterion in BLOCK is true. Passes each item in LIST to BLOCK in turn:

```
printf "%i item(s) are defined", true { defined($_) }, @list;

```

#### Idiomatic Raku ways

```
print "@list.grep(*.defined).elems() item(s) are defined";

```

### false BLOCK, LIST

Counts the number of elements in LIST for which the criterion in BLOCK is false. Passes each item in LIST to BLOCK in turn:

```
printf "%i item(s) are not defined", false { defined($_) }, @list;

```

#### Idiomatic Raku ways

```
print "@list.grep(!*.defined).elems() item(s) are not defined";

```

### reduce\_0 BLOCK, LIST

Reduce LIST by calling BLOCK in scalar context for each element of LIST. The first parameter contains the progressional result and is initialized with **0**. The second parameter contains the currently being processed element of LIST.

```
my $reduced = reduce_0 -> $a, $b { $a + $b }, @list;

```

In the Perl version, `$_` is also set to the index of the element being processed. This is not the case in the Raku version for various reasons. Should you need the index value in your calculation, you can post-increment the anonymous state variable instead: `$++`:

```
my $reduced = reduce_0 -> $a, $b { dd $++ }, @list; # 0 1 2 3 4 5 ...

```

The idea behind reduce\_0 is **summation** (addition of a sequence of numbers).

### reduce\_1 BLOCK, LIST

Reduce LIST by calling BLOCK in scalar context for each element of LIST. The first parameter contains the progressional result and is initialized with **1**. The second parameter contains the currently being processed element of LIST.

```
my $reduced = reduce_1 -> $a, $b { $a * $b }, @list;

```

In the Perl version, `$_` is also set to the index of the element being processed. This is not the case in the Raku version for various reasons. Should you need the index value in your calculation, you can post-increment the anonymous state variable instead: `$++`:

```
my $reduced = reduce_1 -> $a, $b { dd $++ }, @list; # 0 1 2 3 4 5 ...

```

The idea behind reduce\_1 is **product** of a sequence of numbers.

### reduce\_u BLOCK, LIST

Reduce LIST by calling BLOCK in scalar context for each element of LIST. The first parameter contains the progressional result and is initialized with **Any**. The second parameter contains the currently being processed element of LIST.

```
my $reduced = reduce_u -> $a, $b { $a.push($b) }, @list;

```

In the Perl version, `$_` is also set to the index of the element being processed. This is not the case in the Raku version for various reasons. Should you need the index value in your calculation, you can post-increment the anonymous state variable instead: `$++`:

```
my $reduced = reduce_u -> $a, $b { dd $++ }, @list; # 0 1 2 3 4 5 ...

```

The idea behind reduce\_u is to produce a list of numbers.

### minmax LIST

Calculates the minimum and maximum of LIST and returns a two element list with the first element being the minimum and the second the maximum. Returns the empty list if LIST was empty.

```
my ($min,$max) = minmax (43,66,77,23,780); # (23,780)

```

#### Idiomatic Raku ways

```
my $range = <43,66,77,23,780>.minmax( +* );
my $range = (43,66,77,23,780).minmax;   # auto-numerically compares

```

### minmaxstr LIST

Computes the minimum and maximum of LIST using string compare and returns a two element list with the first element being the minimum and the second the maximum. Returns the empty list if LIST was empty.

```
my ($min,$max) = minmaxstr <foo bar baz zippo>; # <bar zippo>

```

#### Idiomatic Raku ways

```
my $range = (43,66,77,23,780).minmax( ~* );
my $range = <foo bar baz zippo>.minmax;  # auto-string compares

```

# SEE ALSO

List::Util, List::AllUtils, List::UtilsBy

# THANKS

Thanks to all of the individuals who have contributed to the Perl version of this module.

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

Source can be located at: <https://github.com/lizmat/List-MoreUtils> . Comments and Pull Requests are welcome.

# COPYRIGHT AND LICENSE

Copyright 2018, 2019, 2020, 2021, 2023 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

Re-imagined from the Perl version as part of the CPAN Butterfly Plan. Perl version originally developed by Tassilo von Parseval, subsequently maintained by Adam Kennedy and Jens Rehsack.


## dist_cpan-BDUGGAN-Protobuf.md
# raku-protobuf

Parse and manage Protobufs with Raku

## Description

This package contains utilities for managing protobufs with Raku.

Current contents:

* Protobuf::Grammar -- parse a protobuf file
* Protobuf::Actions -- generate a representation from a grammar
* Protobuf -- provides `parse-proto` for combining the above
* protoc.raku -- cli to parse a proto from the command line

There are a few other little classes like Protobuf::Definition,
Protobuf::Service, etc which comprise the structure that is
built by Protobuf::Actions.

## SYNOPSIS

```
use Protobuf;

my $p = parse-proto("my.proto".IO.slurp);
# returns a Protobuf::Definition

for $p.services -> $svc {

  # each one is a Protobuf::Service
  say "service name: " ~ $svc.name;

  for $svc.endpoints -> $e {
    # each one is a Protobuf::Endpoint
    say " endpoint:  " ~ $e.name;

    say '  request params: ' ~ $e.request.name;
    # Requests and responses are Protobuf::Message's

    for $e.request.fields -> $f {
      # These are Protobuf::Field's
      say '   name : ' ~ $f.name;
      # Note that type can be a string or a Protobuf::Message
      say '   type : ' ~ $f.type;
    }
    say '  response params: ' ~ $e.response.name;
    for $e.response.fields -> $f {
      say '   name : ' ~ $f.name;
      say '   type : ' ~ $f.type;
    }
  }
}

```

## AUTHOR

Brian Duggan

## TODO

* Generate code from a proto
* A bunch of details in the grammar

## SEE ALSO

<https://developers.google.com/protocol-buffers/docs/reference/proto3-spec>


## dist_zef-tony-o-DB-ORM-Quicky.md
# Quicky ORM

What is it? It's a lazy ORM that I threw together because I end up prototyping a lot of things before building them out with proper schemas. So, it's meant for lazy column typing and minimal code from the user side.

## How it works

The DB::ORM::Quicky::Model (you'll never have to instantiate this object) degrades column types in the order of Int, Num, Str to whatever an equivalent type is in the selected DB. Essentially to `integer`, `float`, `varchar` columns. `varchar` type columns auto resize if the width isn't great enough to hold the requested value.

The model also tracks what columns were changed and *only* updates those fields.

## Example - CRUD (Create Read Update Delete)

For the examples, I'll use SQLite and keep comments to a minimum.

### Depends

[DBIish](https://github.com/perl6/DBIish/)

### [C]rud

```
use DB::ORM::Quicky;

my $orm = DB::ORM::Quicky.new;

$orm.connect(
  driver  => 'SQLite',
  options => %(
    database => 'local.sqlite3',
  )
);

# the `users` table does NOT exist yet.
my $newuser = $orm.create('users'); #this is creating a new 'row', not necessarily a new table

# the `users` table exists with no columns or just a `DBORMID`
#   column (only in SQLite) yet.

$newuser.set({
  username => 'tony-o',
  password => 'top secret',
  age      => 6,
  rating   => 'lame',
  decimal  => 6.66,
});

$newuser.save;  #at this point all required columns are checked or created

```

### c[R]ud

```
my $usersearch = $orm.search('users', { rating => 'lame' });

my @users = $usersearch; #array of all users with 'lame' rating

for $usersearch.next -> $user { ... }

"User count: {$usersearch.count}".say;

```

### cr[U]d

```
for $usersearch.next -> $user {
  $user.set({
    joindate => time, #decided we want to track when a user signed up
  });
  $user.save;
}

```

### cru[D]

```
$orm.search('users', { }).delete; #delete all of our users

```

## More "Advanced" Querying

The ORM can take a lot of different types of values. The usual example by code follows:

```
$orm.search('table', {
  '-or' => [ #-and is also valid
    {
      username => ['user1', 'user2']
    },
    {
      joindate => ('-gt' => time - 5000), # -gt and -lt both work
    },
    '-and' => [
      rating  => 'lame',
      decimal => ('-lt' => 50),
    ]
  ]
});
#  SELECT * FROM table WHERE
#       (username = 'user1' or username = 'user2')
#    OR (joindate > ?)
#    OR (rating = 'lame' and decimal < 50);
#  with ? = (time - 5000)

$orm.search('table', {
  -raw => ' strftime(\'%Y%m%d\', joindate) = strftime(\'%Y%m%d\', \'now\') '
});
#  SELECT * FROM table WHERE strftime('%Y%m%d', joindate) = strftime('%Y%m%d', 'now');

```

### Joining Tables

```
my $orm = qw<initialize your orm as above>;

# initialize some data
my $user = $orm.create('user');
$user.set('username', 'user1');
$user.set('password', 'user1-pass!');
$user.set('source', 'facebook');
$user.save; #$user.id is now an actual value, yay

my $profile = $orm.create('profile');
$profile.set('name', 'tim tow dee');
$profile.set('uid', $user.id);
$profile.set('source', 'facebook');
$profile.save;

# here we'll query them as one unit
my @users = $orm.search('user', { #user table will be our main table
  '-join' => {
    '-table' => 'profile', #join the profile table to user
    '-type'  => 'inner',   #user an inner join, the default is 'left outer'
    '-on'    => {
      '-and' => {
        'uid' => 'DBORMID', #these are autoquoted where the key from the pair is quoted for the joining table and the value is quoted for the main table
                            #you can also use things like a pair here, ie: ('-lt' => 'some other column in user table')
        'source' => 'source', #becomes "profile"."source" = "user"."source" in the SQL
      }
    }
  },
  '"profile"."name"' => ('-ne' => ''), #normal 'where' parameters, notice that quoting the table and field name for the joined table *may* be necessary
}).all;

for my $user (@users) {
  $user.get(qw<any field from either the profile or user table here>);
}

```

The way that the internals work on the `-on` key value pairs is that the `.key` is from the table to be joined, and the `.value` for the parent table. So, the pair of `'uid' => 'DBORMID'` translates to `profile.uid` and `user.DBORMID`, respectively. You can avoid this behavior by providing the table names as part of the field, IE `'profile.uid' => 'user.DBORMID'`

Caveats:

* There isn't a mechanism to use a raw value in the `'-on'` section of the join.
* There is also only one join possible right now.

Both of those features are being worked on.

## Bugs, comments, feature requests?

Yes, there are probably bugs. Put 'em in the github bugs area or catch me in #perl6 on freenode.

## License

Whatever, it's free. Do what you want with it.

###### Other crap

[@tony-o](https://www.gittip.com/tony-o/)


## dist_cpan-BDUGGAN-Dawa.md
## NAME

Dawa -- A runtime debugger for Raku programs

## SYNPOSIS

Use from the command line with the `dawa` command:

![image](https://user-images.githubusercontent.com/58956/213559772-15101247-a7f6-4e45-9b3e-2954f2b7cf90.png)

Use from within a program with the `stop` statement:

![image](https://user-images.githubusercontent.com/58956/213560033-dfce1bb2-0924-4169-b498-3c5920cf2660.png)

## DESCRIPTION

Dawa is a run-time debugger for Raku programs.

It exports one subroutine: `stop`, which will pause
execution of the current thread of the program, and
allow for introspecting the stack, and stepping through
subsequent statements. It also supports debugging of
multi-threaded programs.

Importing `Dawa` adds extra ops to the AST that is
generated during compilation. Specifically, it adds
at most one extra node per line. There is a significant
perforance penalty for this, as well as a risk that your
program will break. Patches welcome!

The functionality of `dawa` is inspired by
Ruby's [pry](https://github.com/pry/pry) and Python's
[pdb](https://docs.python.org/3/library/pdb.html).

## USAGE

After `stop` is reached, a repl is started, which has a few
commands. Type `h` to see them. Currently, these are the commands:

```
       break (b) : [N [filename] ] add a breakpoint at line N [in filename]
continue (c, ^D) : continue execution of this thread
       defer (d) : [n] Defer to thread [n], or the next waiting one
        eval (e) : [id] evaluate code in the current context [or in thread #id]
        help (h) : this help
          ls (l) : [-a] [id] show [all] lexical variables in the current scope [or in thread #id]
        next (n) : run the next statement in any thread
        quit (q) : terminate the program (exit)
        step (s) : execute the next statement in the same thread
     threads (t) : [id] show threads being tracked [or just thread #id]
       where (w) : show a stack trace and the current location in the code

```

Anything else is treated as a Raku statement: it will be evaluated,
the result will be shown.

### Breakpoints

Breakpoints can be set with `b`, for example:

```
  dawa [1]> b 13
  Added breakpoint at line 13 in eg/debug.raku

```

As shown above, breakpoints are indicated using `■` and are not
thread-specific. The triangle (▶) is the line of code that
will be executed next. The `[1]` indicates that this is thread 1.
The `[1]` in the prompt indicates that statements will currently
be evaluated in the context of thread 1 by default.

## Details of "next"

In Raku, there can be multiple statements per line, and multiple
"statements" within a statement, which makes it tricky to debug a
program by stepping through "statements" or stepping through "lines".
Dawa has a number of heuristics for when to stop, but the idea is to
stop at most once per line and at most once per statement. Typing "n"
may sometimes stay within the same block of code, if a statement containing
other statements spans several lines. The display will indicate
the block of code containing the statement that will be executed.

## Multiple Threads

If several threads are stopped at once, a lock is used in order to
only have one repl at a time. Threads wait for this lock. After
either continuing or going on to the next statement, another thread
that is waiting for the lock may potentially become active in the repl.
i.e. "next" advances to the next statement in any thread. To stay in
the same thread, use "step".

```
∙ Stopping thread Thread #1 (Initial thread)

--- current stack ---
  in block <unit> at example.raku line 11

-- current location --
   3 │       │ my $i = 1;
   4 │       │
   5 │       │ start loop {
   6 │       │   $i++;
   7 │   [7] │   $i++;
   8 │       │ }
   9 │       │
  10 │  [1]▶ │ stop;
  11 │       │ say 'bye!';
  12 │       │

Type h for help
dawa [1]>

```

Note that in this situation thread 7 continues to run even while the repl
is active. To also stop thread 7 while debugging, you can add a breakpoint
(since breakpoints apply to all threads).

The `eval` command can be used to evaluate expression in another thread. For instance,
`eval 7 $i` will evaluate the `$i` in thread 7.

The `ls` command can show lexical variables in another thread. Note that only variables
in the innermost lexical scope will be shown.

The `defer` command can be used to switch to another stopped thread. Here is an example:

### Switching between threads

When multiple threads are stopped, `defer` will switch from one to another.
For instance, the example below has `eg/defer.raku`, with threads 7-11 stopped,
as well as thread 1. After looking at the stack in thread 1, typing `d 8`
will change to thread 8, and subsequent commands will run in the context
of that thread. (also note that if a lot of threads are stopped at the same
line of code, they are shown in a footnote)

```
dawa [1]> w

--- current stack ---
  in block <unit> at eg/defer.raku line 16

-- current location --
   4 │       │   start {
   5 │       │     my $x = 10;
   6 │       │     loop {
   7 │       │       stop;
   8 │   (a) │       $x++;
   9 │       │     }
  10 │       │   }
  11 │       │ }
  12 │       │
  13 │       │ my $y = 100;
  14 │       │ loop {
  15 │       │   stop;
  16 │  [1]▶ │   say "y is $y";
  17 │       │   $y += 111;
  18 │       │   last if $y > 500;
  19 │       │ }
  20 │       │
────────────────────────────────────────
(a) : [8][9][7][10][11]
────────────────────────────────────────

dawa [1]> d 8
  8 ▶       $x++;
dawa [8]> w

--- current stack ---
  in block  at eg/defer.raku line 8

-- current location --
  4 │       │   start {
  5 │       │     my $x = 10;
  6 │       │     loop {
  7 │       │       stop;
  8 │  (a)▶ │       $x++;
  9 │       │     }
 10 │       │   }
 11 │       │ }
 12 │       │
 13 │       │ my $y = 100;
 14 │       │ loop {
 15 │       │   stop;
 16 │   [1] │   say "y is $y";
 17 │       │   $y += 111;
 18 │       │   last if $y > 500;
 19 │       │ }
 20 │       │
────────────────────────────────────────
(a) : [8][9][7][10][11]
────────────────────────────────────────

dawa [8]> $x
10

```

## ABOUT THE NAME

The word `dawa` can refer to either medicine or poison in Swahili. In the
latter sense, it would be used to describe bug spray, i.e. a debugger -- but
hopefully it'll also help be a cure for any ailments in your programs.

## SEE ALSO

1. There is a built-in `repl` statement, which will pause execution
   and start a repl loop at the current location.
2. [rakudo-debugger](https://github.com/jnthn/rakudo-debugger) provides
   a separate executable for debugging. Techniques there inspired
   this module.

## ENVIRONMENT

The readline history is stored in `DAWA_HISTORY_FILE`, ~/.dawa-history by default.

## BUGS

Since this relies on undocumented behavior, it could break at any time. Modifying
the AST may also cause your program to behave in unexpected ways. It may be
possible to improve this once the AST work in Raku is available.

## MAILING LIST

<https://lists.sr.ht/~bduggan/raku-dawa>

## AUTHOR

Brian Duggan (bduggan at matatu.org)


## dist_zef-l10n-L10N-DE.md
# NAME

L10N::DE - German localization of Raku

# SYNOPSIS

```
use L10N::DE;
sag "Hello World";

```

# DESCRIPTION

L10N::DE contains the logic to provide a German localization of the Raku Programming Language.

# AUTHORS

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

# COPYRIGHT AND LICENSE

Copyright 2023 Raku Localization Team

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## mixy.md
role Mixy

Collection of distinct objects with Real weights

```raku
role Mixy does Baggy { }
```

A role for collections of weighted values. See [`Mix`](/type/Mix) and [`MixHash`](/type/MixHash). `Mixy` objects differ from [`Baggy`](/type/Baggy) objects in that the weights of `Mixy` are [`Real`](/type/Real)s rather than [`Int`](/type/Int)s.

# [Methods](#role_Mixy "go to top of document")[§](#Methods "direct link")

## [method roll](#role_Mixy "go to top of document")[§](#method_roll "direct link")

```raku
method roll($count = 1)
```

Similar to a [`Bag`](/type/Bag).roll, but with [`Real`](/type/Real) weights rather than integral ones.

## [method pick](#role_Mixy "go to top of document")[§](#method_pick "direct link")

```raku
method pick($?)
```

Throws an exception. The feature is not supported on the type, since there's no clear value to subtract from non-integral weights, to make it work.

## [method grab](#role_Mixy "go to top of document")[§](#method_grab "direct link")

```raku
method grab($?)
```

Throws an exception. The feature is not supported on the type, since there's no clear value to subtract from non-integral weights, to make it work.

## [method kxxv](#role_Mixy "go to top of document")[§](#method_kxxv "direct link")

```raku
method kxxv()
```

Throws an exception. The feature is not supported on the type, since there's no clear value to subtract from non-integral weights, to make it work.

# [See Also](#role_Mixy "go to top of document")[§](#See_Also "direct link")

[Sets, Bags, and Mixes](/language/setbagmix)

# [Typegraph](# "go to top of document")[§](#typegraphrelations "direct link")

Type relations for `Mixy`

raku-type-graph

Mixy
Mixy

Baggy
Baggy

Mixy->Baggy

Associative
Associative

QuantHash
QuantHash

QuantHash->Associative

Baggy->QuantHash

Mu
Mu

Any
Any

Any->Mu

Mix
Mix

Mix->Mixy

Mix->Any

MixHash
MixHash

MixHash->Mixy

MixHash->Any

[Expand chart above](/assets/typegraphs/Mixy.svg)


## dist_github-ufobat-XML-XPath.md
# XML::XPath

[![Build Status](https://travis-ci.org/ufobat/p6-XML-XPath.png)](https://travis-ci.org/ufobat/p6-XML-XPath)
[![Build status](https://ci.appveyor.com/api/projects/status/github/ufobat/p6-XML-XPath?svg=true)](https://ci.appveyor.com/project/ufobat/p6-XML-XPath/branch/master)

A Perl 6 Library for parsing and evaluating XPath Statements.

# XPath Specification

Specification on XPath Expressions can be found at <https://www.w3.org/TR/xpath/>.

# Synopsis

```

use XML::XPath;

my $xpath  = XML::XPath.new(xml => '... xml ...');
my $result = $xpath.find('/foo/bar');

```

# Example

If you want to see more examples please have a look at the [testcases](t).

# Documentation

## `XML::XPath.new(:$file, :$xml, :$document)`

XML::XPath creates a XML Document from a `$file` or from `$xml` unless you provide a `$document` in the constructor.

## `.find(Str $xpath, XML::Node :$start, Bool :$to-list)`

Evaluates the XPath Expression and returns the results of the match. If a $start node is provided it starts
there instead of beginning of the XML Document.
If $to-list is True the result will allways be an Array, otherwise it might return Any or a single element
(e.g XML::Node, Str, Nummeric, Bool)

## `.set-namespace(Pair $ns)`

This method sets a namespace, so the value of `$ns.key` can be used in the XPath expression to look nodes a
certain namespace.

```

$x.set-namespace: 'goo' => "foobar.example.com";
$set = $x.find('//goo:something');

```

## `.clear-namespaces`

Clears all namespaces that have been set via `.set-namespace`.

## `.parse-xpath(Str $xpath)`

Just parses `$xpath` expression.

# License

Artistic License 2.0.


## dist_zef-raku-community-modules-Docker-File.md
[![Actions Status](https://github.com/raku-community-modules/Docker-File/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/Docker-File/actions) [![Actions Status](https://github.com/raku-community-modules/Docker-File/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/Docker-File/actions) [![Actions Status](https://github.com/raku-community-modules/Docker-File/actions/workflows/windows.yml/badge.svg)](https://github.com/raku-community-modules/Docker-File/actions)

# NAME

Docker::File - Parsing and generation of Dockerfiles

# SYNOPSIS

```
use Docker::File;

# Parse a Dockerfile into a bunch of objects.
my $parsed-df = Docker::File.parse($docker-file);
unless $parsed-df.instructions.grep(Docker::File::Maintainer) {
    note "This Dockerfile has no maintainer! :-("
}

# Generate a Dockerfile.
my $new-df = Docker::File.new(
  images => [
    Docker::File::Image.new(
      from-short => 'ubuntu',
      from-tag => 'latest'
      entries => [
        Docker::File::RunShell.new(
          command => 'sudo apt-get install raku'
        )
      ]
    )
  ]
);
say ~$new-df;

```

# DESCRIPTION

A Raku module to read/write docker files.

# AUTHOR

Jonathan Worthington

# COPYRIGHT AND LICENSE

Copyright 2016 - 2017 Jonathan Worthington

Copyright 2024 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-lizmat-has-word.md
[![Actions Status](https://github.com/lizmat/has-word/actions/workflows/linux.yml/badge.svg)](https://github.com/lizmat/has-word/actions) [![Actions Status](https://github.com/lizmat/has-word/actions/workflows/macos.yml/badge.svg)](https://github.com/lizmat/has-word/actions) [![Actions Status](https://github.com/lizmat/has-word/actions/workflows/windows.yml/badge.svg)](https://github.com/lizmat/has-word/actions)

# NAME

has-word - A quick non-regex word-boundary checker

# SYNOPSIS

```
use has-word;

say has-word("foobarbaz", "foo");                   # False
say has-word("foo barbaz", "foo");                  # True
say has-word("foo::bar::baz", "bar");               # True
say has-word("foo::bar::baz", "BAZ", :ignorecase);  # True
say has-word("foo::bar::báz", "baz", :ignoremark);  # True

.say for all-words("foo bar FOO", "foo", :i);       # foo␤FOO␤

.say for find-all-words("foo bar foo", "foo");      # 0␤8␤

```

# DESCRIPTION

The `has-word` module exports a two subroutines that provide a quick way to see whether a string occurs as a "word" (defined as a number of alphanumeric characters surrounded by either non-alphanumeric characters or the beginning or end of the string. As such, it provides the equivalent of the `word` functionality in regular expressions, but much faster and with a simpler way of checking for words that cannot be determined at compile time.

# SUBROUTINES

## has-word

```
say has-word("foobarbaz", "foo");                   # False
say has-word("foo barbaz", "foo");                  # True
say has-word("foo::bar::baz", "bar");               # True
say has-word("foo::bar::baz", "BAZ", :ignorecase);  # True

```

The `has-word` subroutine takes the haystack string as the first positional argument, and the needle string as the second positional argument. It also optionally takes an `:ignorecase` (or `:i`) named argument to perform the search in a case-insensitive manner, and/or an `:ignoremark` (or `:m`) named argument to perform the search by only comparing the base characters.

It returns either `True` if found, or `False` if not.

## all-words

```
.say for all-words("foo bar FOO", "foo", :i);      # foo␤FOO␤

```

The `all-words` subroutine takes the haystack string as the first positional argument, and the needle string as the second positional argument. It also optionally takes an `:ignorecase` (or `:i`) named argument to perform the search in a case-insensitive manner, and/or an `:ignoremark` (or `:m`) named argument to perform the search by only comparing base characters. It returns a `Slip` with the found strings (which can be different from the given needle if `:ignorecase` or `:ignoremark` were specified.

## find-all-words

```
.say for find-all-words("foo bar foo", "foo");      # 0␤8␤

```

The `find-all-words` subroutine takes the haystack string as the first positional argument, and the needle string as the second positional argument. It also optionally takes an `:ignorecase` (or `:i`) named argument to perform the search in a case-insensitive manner, and/or an `:ignoremark` (or `:m`) named argument to perform the search by only comparing base characters. It returns a `List` of positions in the haystack string where the needle string was found.

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

# COPYRIGHT AND LICENSE

Copyright 2021, 2022, 2024 Elizabeth Mattijsen

Source can be located at: <https://github.com/lizmat/has-word> . Comments and Pull Requests are welcome.

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_cpan-AVUSEROW-Net-Snapcast.md
[![Actions Status](https://github.com/avuserow/raku-net-snapcast/actions/workflows/test.yml/badge.svg)](https://github.com/avuserow/raku-net-snapcast/actions)

# NAME

Net::Snapcast - Control Snapcast audio players

# SYNOPSIS

```
use Net::Snapcast;

my $sc = Net::Snapcast.new(:$host, :port(1705));

# list clients attached to snapcast
my @clients = $sc.list-clients;

# change volume on a client
$sc.set-volume(@clients[0].id, 100);

# get a supply of events (from other clients only)
# see documentation at https://github.com/badaix/snapcast/blob/master/doc/json_rpc_api/control.md#notifications
$sc.notifications.tap(-> $e {
    say "event type $e<method>: $e<params>";
})

```

# DESCRIPTION

Net::Snapcast is an interface for controlling players connected to a Snapcast server. Snapcast is a client/server system for building a multiroom audio system. The server consumes audio from one or more sources, controls which client receives which audio stream, and manages latency to keep audio playback synchronized. See <https://github.com/badaix/snapcast> for more details on Snapcast.

This module implements the control interface to Snapcast, allowing you to manage the various players. You can programmatically control what client is connected to which stream, change the volume, and receive notifications of changes made by other clients.

This module does not implement any audio sending or receiving. In snapcast terms, this implements the "Control API" (on port 1705 by default).

This module is currently tested with a Snapcast server running 0.25.0.

# METHODS

## new(:$host, :$port)

Connects to the given Snapcast server and synchronizes the state.

## sync

Re-sync cached snapcast data. This is called automatically as needed and should not need to be invoked manually.

## notifications

Returns a Supply that receives events from other clients. If this client makes an RPC call (e.g. `set-volume`), then this Supply will not receive an event.

Events are documented at <https://github.com/badaix/snapcast/blob/master/doc/json_rpc_api/control.md#notifications> and may vary depending on the Snapcast server.

## list-clients

Returns a list of clients. See the `Net::Snapcast::Snapclient` class below for the included attributes.

## set-volume($id, $volume)

Sets the volume level of the provided client.

# SUBCLASSES

## Snapclient - details about a connected client

This class is returned from `list-clients`. This is called "snapclient" after the snapcast player command's name. All attributes should be considered read-only.

### Client Attributes

* Str id - snapcast-assigned client ID, defaults to MAC address with optional instance ID
* Str name - configured client name, as set by the snapcast API `Client.SetName`. Defaults to hostname if unset, and there may be duplicate client names.
* Int instance - instance ID of the snapcast clients. Defaults to 1 and only changed when running multiple clients per computer
* Str hostname - hostname of the computer running this client
* Str os - operating system of this client
* Str ip - IP address of this client
* Str arch - architecture of this client (e.g. `x86_64`, `armv6l`, `arm64-v8a`)
* Str mac - MAC address of this client, if available (otherwise may be all zeroes)
* Bool connected - indicates whether this client is currently connected to snapcast (or if the server just remembers this client). You can still modify attributes of disconnected clients, but they disappear upon server restart.
* Bool muted - indicates whether this client is muted in snapcast
* Int volume - indicates volume level within snapcast
* Str group-id - ID of the group containing this client (NOTE: group APIs are not yet implemented)
* Str stream-id - ID of the audio stream that this client is consuming (actually the "name" of the stream in snapcast config)

# SEE ALSO

<https://github.com/badaix/snapcast> - snapcast repo

<https://github.com/badaix/snapcast/blob/master/doc/json_rpc_api/control.md> - documentation for control protocol

# AUTHOR

Adrian Kreher [avuserow@gmail.com](mailto:avuserow@gmail.com)

# COPYRIGHT AND LICENSE

Copyright 2022 Adrian Kreher

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_github-taboege-SAT-Solver-MiniSAT.md
# NAME

SAT::Solver::MiniSAT - SAT solver MiniSAT

# SYNOPSIS

```
use SAT::Solver::MiniSAT;

say minisat "t/aim/aim-100-1_6-no-1.cnf".IO, :now;
#= False
say minisat "t/aim/aim-100-1_6-yes1-1.cnf".IO, :now;
#= True

```

# DESCRIPTION

SAT::Solver::MiniSAT wraps the `minisat` executable (bunled with the module) used to decide whether a satisfying assignment for a Boolean formula given in the `DIMACS cnf` format exists. This is known as the `SAT` problem associated with the formula. MiniSAT does not produce a witness for satisfiability.

Given a DIMACS cnf problem, it starts `minisat`, feeds it the problem and returns a Promise which will be kept with the `SAT` answer found or broken on error.

# AUTHOR

Tobias Boege <tboege ☂ ovgu ☇ de>

# COPYRIGHT AND LICENSE

Copyright 2018 Tobias Boege

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_cpan-SAMGWISE-HTML-Lazy.md
[![Build Status](https://travis-ci.org/samgwise/html-lazy.svg?branch=master)](https://travis-ci.org/samgwise/html-lazy)

# NAME

HTML::Lazy - Declarative HTML generation

# SYNOPSIS

```
use HTML::Lazy (:ALL);

my $document = html-en
    head( Map,
        title(Map, text('HTML::Lazy'))
    ),
    body( Map,
        p({ :class<example> },
            text('Hello world!')
        )
    );

# Execute the generator and show the new HTML
put render($document)

```

And the result:

# output

Hello world!

# DESCRIPTION

HTML::Lazy is a declarative HTML document generation module. It provides declarative functions for creating lazy HTML generation closures. The lazy generation can be overridden through an eager renderer and generation can be performed in parrallel with a hyper-renderer.

## Tags and adding your own

For a list of html tags which can be exported, see the export list below. If you need one I've missed, you can generate your own tag function like this:

```
my &head = tag-factory 'head';

```

You now have a routine for generating head tags.

## Prior Art

This is certainly not the first Perl 6 HTML generator and will hardly be the lasst. A number of other modules provide differnt solutions which you should consider:

* [XHTML::Writer](https://github.com/gfldex/perl6-xhtml-writer)
* [Typesafe::XHTML::Writer](https://github.com/gfldex/perl6-typesafe-xhtml-writer)
* [HTML::Tag](https://github.com/adaptiveoptics/HTML-Tag)

# AUTHOR

Sam Gillespie [samgwise@gmail.com](mailto:samgwise@gmail.com)

# COPYRIGHT AND LICENSE

Copyright 2019 Sam Gillespie.

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

# Export groups

| Symbol | Export groups |
| --- | --- |
| &render | :DEFAULT, :ALL |
| &pre-render | :DEFAULT, :ALL |
| &hyper-render | :DEFAULT, :ALL |
| &text | :DEFAULT, :ALL |
| &text-raw | :DEFAULT, :ALL |
| &node | :DEFAULT, :ALL |
| &tag-factory | :DEFAULT, :ALL |
| &with-attributes | :DEFAULT, :ALL |
| &html-en | :DEFAULT, :ALL |
| &include-file | :DEFAULT, :ALL |
| &head | :tags, :ALL |
| &title | :tags, :ALL |
| &meta | :tags, :ALL |
| &body | :tags, :ALL |
| &div | :tags, :ALL |
| &footer | :tags, :ALL |
| &header | :tags, :ALL |
| &br | :tags, :ALL |
| &col | :tags, :ALL |
| &colgroup | :tags, :ALL |
| &ul | :tags, :ALL |
| &ol | :tags, :ALL |
| &li | :tags, :ALL |
| &code | :tags, :ALL |
| &samp | :tags, :ALL |
| &pre | :tags, :ALL |
| &table | :tags, :ALL |
| &thead | :tags, :ALL |
| &tbody | :tags, :ALL |
| &tfoot | :tags, :ALL |
| &tr | :tags, :ALL |
| &th | :tags, :ALL |
| &td | :tags, :ALL |
| &caption | :tags, :ALL |
| &figure | :tags, :ALL |
| &figurecaption | :tags, :ALL |
| &a | :tags, :ALL |
| &img | :tags, :ALL |
| &audio | :tags, :ALL |
| &video | :tags, :ALL |
| &canvas | :tags, :ALL |
| &link | :tags, :ALL |
| &script | :tags, :ALL |
| &style | :tags, :ALL |
| &asource | :tags, :ALL |
| &svg | :tags, :ALL |
| &noscript | :tags, :ALL |
| &iframe | :tags, :ALL |
| &template | :tags, :ALL |
| &form | :tags, :ALL |
| &input | :tags, :ALL |
| &label | :tags, :ALL |
| &optgroup | :tags, :ALL |
| &option | :tags, :ALL |
| &select | :tags, :ALL |
| &textarea | :tags, :ALL |
| &button | :tags, :ALL |
| &span | :tags, :ALL |
| &p | :tags, :ALL |
| &i | :tags, :ALL |
| &b | :tags, :ALL |
| &q | :tags, :ALL |
| &blockquote | :tags, :ALL |
| &em | :tags, :ALL |
| &sub | :tags, :ALL |
| &sup | :tags, :ALL |
| &h1 | :tags, :ALL |
| &h2 | :tags, :ALL |
| &h3 | :tags, :ALL |
| &h4 | :tags, :ALL |
| &h5 | :tags, :ALL |
| &h6 | :tags, :ALL |

# Subroutines

### sub render

```
sub render(
    &tag
) returns Str

```

Calls a no argument Callable to produce the defined content. This routine is here to show programmer intention and catch any errors encountered when building the HTML Str. All errors are returned in the form of a failure so it is important to check the truthiness of the result to determine if the HTML was generated succesfully.

### sub pre-render

```
sub pre-render(
    &tag
) returns Callable

```

Executes a render and stores the result so it may be rendered later. Use this function to eagerly evaluate a document or sub document and store the resulting Str for use in other documents. Please note that any errors encountered during a pre-render will not be encountered until the result of the pre-rendered output is used, since the Failure object will be caputred in the result.

### sub hyper-render

```
sub hyper-render(
    *@children
) returns Callable

```

Children of a hyper-render function will be rendered in parrallel when called. The results will be reassembled without change to order.

### sub text

```
sub text(
    Str $text
) returns Callable

```

Create a closure to emit the text provided. Text is escaped for HTML, use `text-raw` for including text which should not be sanitised. The escaping uses escape-html from `HTML::Escape` (<https://modules.perl6.org/dist/HTML::Escape:cpan:MOZNION)>.

### sub text-raw

```
sub text-raw(
    Str $text
) returns Callable

```

Create a closure to emit the text provided. The text is returned with no escaping. This function is appropriate for inserting HTML from other sources, scripts or CSS. If you are looking to add text content to a page you should look at the `text` function as it will sanitize the input, so as to avoid any accidental or malicious inclusion of HTML or script content.

### sub node

```
sub node(
    Str:D $tag,
    Associative $attributes,
    *@children
) returns Callable

```

Generalised html element generator. This function provides the core rules for generating html tags. All tag generators are built upon this function. To create specialised versions of this function use the `tag-factory` and then further specialised with the C function.

### sub tag-factory

```
sub tag-factory(
    Str:D $tag
) returns Callable

```

Make functions to create specific tags. Returns a Callable with the signiture (Associative $attributes, \*@children --> Callable). The closure created by this routine wraps up an instance of the `node` routine.

### sub with-attributes

```
sub with-attributes(
    &tag,
    Associative $attributes
) returns Callable

```

Create a tag with preset attributes. Allows for further specialisation of tag closures from the C routine. The closure returned from this routine has the following signiture (\*@children --> Callable).

### sub html-en

```
sub html-en(
    Associative :$attributes = { ... },
    *@children
) returns Callable

```

Create a HTML tag with DOCTYPE defenition. Use this function as the top of your document. The default arguments to attributes are set for English, `{:lang<en>, :dir<ltr>}`, but a new Map or hash can be used to tailor this routine to your needs.

### sub include-file

```
sub include-file(
    Str:D $file
) returns Callable

```

Include content from a file. Use this function to include external files such as scripts and CSS in your templates. Content is included without any sanitisation of the input.


## before.md
before

Combined from primary sources listed below.

# [In StrDistance](#___top "go to top of document")[§](#(StrDistance)_method_before "direct link")

See primary documentation
[in context](/type/StrDistance#method_before)
for **method before**.

This is actually a class attribute, and called as a method returns the string before the transformation:

```raku
say $str-dist.before; # OUTPUT: «fold␤»

```

# [In Operators](#___top "go to top of document")[§](#(Operators)_infix_before "direct link")

See primary documentation
[in context](/language/operators#infix_before)
for **infix before**.

```raku
multi infix:<before>(Any,       Any)
multi infix:<before>(Real:D,    Real:D)
multi infix:<before>(Str:D,     Str:D)
multi infix:<before>(Version:D, Version:D)
```

Generic ordering, uses the same semantics as [cmp](/routine/cmp). Returns `True` if the first argument is smaller than the second.


## dist_zef-jonathanstowe-Oyatul.md
# Oyatul

Abstract representation of a filesystem layout

![Build Status](https://github.com/jonathanstowe/Tinky/workflows/CI/badge.svg)

## Synopsis

This runs the tests identified by 'purpose' test which can be in any
location in the layout with the library directory identified by the
purpose 'lib' :

```
use Oyatul;

my $description = q:to/LAY/;
{
   "type" : "layout",
   "children" : [
      {
         "name" : "t",
         "purpose" : "tests",
         "type" : "directory",
         "children" : [
            {
               "type" : "file",
               "purpose" : "test",
               "template" : true
            }
         ]
      },
      {
         "type" : "directory",
         "purpose" : "lib",
         "name" : "lib",
         "children" : []
      }
   ]
}
LAY

# the :real adverb causes instance nodes to be inserted
# for any templates if they exist.
my $layout = Oyatul::Layout.from-json($description, root => $*CWD.Str, :real);

# get the directory that stands in for 'lib'
my $lib = $layout.nodes-for-purpose('lib').first.path;

# get all the instances for 'test' excluding the template
for $layout.nodes-for-purpose('test', :real) -> $test {
	run($*EXECUTABLE, '-I', $lib, $test.path);
}

```

## Description

This provides a method of describing a filesystem layout in an abstract
manner.

It can be used in the deployment of applications which might need
the creation of a directory tree for data or configuration, or for
applications which may need to locate files and directory that it needs
but can allow the user to define their own .

The file layout descriptions can be stored as JSON or they can be built
programmatically (thus allowing other forms of storage.)

The description can define directories and files in an aribitrary tree
structure, each can optionally define a 'purpose' which can be used to
locate a node irrespective of its location in the tree and name, a node
object can also be given a role with the 'does' key which can give the
node additional behaviours (e.g. create a file of a specific format,
create an object based on a file or directory etc.) Template nodes can
be defined which can stand in for real files or directories which can
be discovered at run-time.

This is based on a design that I used in a large application that relied
heavily on file storage for its data, but is somewhat more simplified
and abstracted as well as preferring JSON over the original XML for the
storage of the layout description. The features are designed to allow
[Sofa](https://github.com/jonathanstowe/Sofa) to load a CouchDB design
document from an arbitrary (possibly user defined) file hierarchy unlike
`couchapp` which requires a fixed directory structure. However
hopefully it will be useful in other applications.

## Installation

Assuming you have a working Rakudo installation you should be able to install this with *zef* :

```
# From the source directory

zef install .

# Remote installation

zef install Oyatul

```

## Support

Suggestions and patches that may make it more useful in your software are welcomed via github at:

<https://github.com/jonathanstowe/Oyatul/issues>

## Licence

This is free software.

Please see the <LICENCE> file in the distribution

© Jonathan Stowe 2016 - 2021


## dist_zef-jmaslak-Sys-HostAddr.md
[![Build Status](https://travis-ci.org/jmaslak/Raku-Sys-HostAddr.svg?branch=master)](https://travis-ci.org/jmaslak/Raku-Sys-HostAddr)

# NAME

Sys::Domainname - Get IP address information about this host

# SYNOPSIS

```
use Sys::Domainname;

my $sysaddr = Sys::HostAddr.new;
my $string = $sysaddr->public;

my @addresses = $sysaddr->addresses;
my @interfaces = $sysaddr->interfaces;
my @on-int-addresses = $sysaddr->addresses-on-interface('eth0');

```

# DESCRIPTION

This module provides methods for determining IP address information about a local host.

# WARNING

This module only functions on relatively recent Linux.

# ATTRIBUTES

## ipv

This attribute refers to the IP Version the class operates against. It must be set to either `4` or `6`. This defaults to `4`.

## ipv4-url

This is the API URL used to obtain the host's public IPv4 address. It defaults to using `https://api.ipify.org`. The URL must return the address as a plain text response.

## ipv6-url

This is the API URL used to obtain the host's public IPv4 address. It defaults to using `https://api6.ipify.org`. The URL must return the address as a plain text response.

## user-agent

This is the user agent string used to idenfiy this module when making web calls. It defaults to this module's name and version.

## filter-localhost

If `filter-localhost` is true, only non-localhost addresses will be returned by this class's methods. This defaults to true.

Localhost is defined as any IPv4 address that begins with `127.` or the IPv6 address `::1`.

## filter-link-local

If `filter-link-local` is true, only non-link-local addresses will be returned by this class's methods. This defaults to true and has no impact when `ipv` is set to `4`.

Link local is defined as any IPv4 address that belong to `fe80::/10`.

# METHODS

## public(-->Str:D)

```
my $ha = Sys::HostAddr.new;
say "My public IP: { $ha.public }";

```

Returns the public IP address used by this host, as determined by contacting an external web service. When the `ipv` property is set to `6`, this may return an IPv4 address if the API endpoint is not reachable via IPv6.

## interfaces(-->Seq:D)

```
my $ha = Sys::HostAddr.new;
@interfaces = $ha.interfaces.list;

```

Returns the interface names for the interfaces on the system. Note that all interfaces available to the `ip` command will be returned, even if they do not have IP addresses assigned. If the `ip` command cannot be executed (for instance, on Windows), this will return a sequene with no members.

## addresses(-->Seq:D)

```
my $ha = Sys::HostAddr.new;
@addresses = $ha.addresses.list;

```

Returns the addresses on the system. If the `ip` command cannot be executed (for instance, on Windows), this will return a sequene with no members.

## addresses-on-interface(Str:D $interface -->Seq:D)

```
my $ha = Sys::HostAddr.new;
@addresses = $ha.addresses-on-interface("eth1").list;

```

Returns the addresses on the interface provided. If the `ip` command cannot be executed (for instance, on Windows), this will return a sequene with no members.

## guess-ip-for-host(Str:D $ip -->Str)

```
my $ha = Sys::HostAddr.new;
$address = $ha.guess-ip-for-host('192.0.2.1');

```

Returns an address associated with the interface used to route packets to the given destination. Where more than one address exists on that interface, or more than one interface has a route to the given host, only one will be returned.

This will return `Str` (undefined type object) if either the host isn't routed in the routing table or if the `ip` command cannot be executed (for instance, on Windows).

## guess-main(-->Str)

```
my $ha = Sys::HostAddr.new;
$address = $ha.guess-main-for-ipv4

```

Returns the result of either `.guess-ip-for-host('0.0.0.0')` or `.guess-ip-for-host('2000::')` depending on the value of `$.ipv4`.

## guess-main-for-ipv6(-->Str)

```
my $ha = Sys::HostAddr.new;
$address = $ha.guess-main-for-ipv6

```

Returns the result of `.guess-ip-for-host('2000::')`.

# AUTHOR

Joelle Maslak [jmaslak@antelope.net](mailto:jmaslak@antelope.net)

Inspired by Perl 5 `Sys::Hostname` by Jeremy Kiester.

# COPYRIGHT AND LICENSE

Copyright © 2020-2022 Joelle Maslak

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_cpan-CTILMES-Native-Compile.md
# Native::Compile - Native Compiling for Raku Modules

# SYNOPSIS

```
# META6.json
"resources" : [ "libraries/mylib" ]

# MyModule.rakumod
my constant LIB = %?RESOURCES<libraries/mylib>;
sub myfunc() is native(LIB) {}

# A Simple Build.rakumod example:
use Native::Compile;
class Build {
  method build($dir) {
      build :$dir, :lib<mylib>, :src<src/myfile.c>
  }
}

# More explicit separate steps Build.rakumod:
use Native::Compile;
class Build {
    method build($dir) {
        indir $dir, {
            my $obj = compile('src/myfile.c');
            link('mylib', @$obj);
        }
    }
}

# A more complicated Build.rakumod:
use Native::Compile;
class Build {
  method build($dir, :$verbose, :$dryrun) {
      build :$dir, :lib<mylib>, :src<src/myfile.c>, :cc<clang>,
      :extra-cflags<-O>, :$verbose, :$dryrun, :clean,
      fallback => [ %( :os<windows>              # special name for windows
                       :url<http://somewhere/mylib.dll>,
                       :hash<abcd343534...> ),   # SHA256
                    %( :os<darwin>,
                       :version(v10.14+),        # Version comparisons
                       :url<http://somewhere/mylib.dylib>,
                       :hash<abcd343534...> ) ]
  }
}

```

# DESCRIPTION

Compile C and C++ sources, linking them into a shared library in the
module resources. If a prebuilt library is available for Windows or
Mac OS/X, it can download it if a compiler is not available.

This module also exports a `MAIN` subroutine so you can make your
`Build.rakumod` executable and things will just work. It takes the
*-v* / *--verbose* and *-n* / *--dryrun* flags and passes them on to
the `Build.build()`, which can be useful for debugging the build
process.

It exports a number of subroutines that capture what I've observed as
frequent boilerplate for doing this sort of thing throughout the
ecosystem. Many examples seem to do it slightly differently, and I'm
not sure this is yet optimal. This is still a work in progress, and
the interface may still change. I'd like to support the most common
cases here, making easy things easy. Hopefully the **build**
subroutine is all you really need, though the other functions are
exposed if they are useful. You can manually perform the compile/link
steps in class `Build` if needed.

This module is modelled after, and draws from LibraryMake. It doesn't have
the full capabilities of LibraryMake, but for very simple and common cases,
it reduces the amount of required boilerplate. If you need more complex
capabilities, just write a full Makefile and use LibraryMake.

That said, if there is a capability you think would fit into this module,
please propose, either an idea, or even a patch.

# SUBROUTINES

### sub get-vars(\*%args)

Get various compiling variables ala LibraryMake Many of the variables
are retrieved from the VM, based on the original system
compilation. Some are overridden by more appropriate choice. Each of
the variables can also be overridden by named parameters passed in to
this routine, and finally by Environment variables.

### sub win-hash($path, :$verbose, :$dryrun)

Use Windows powershell to compute a sha256 hash of a file

### sub win-fetch($url, $file, :$verbose, :$dryrun)

Use Windows powershell to download a file from a url

### sub openssl-hash($path, :$verbose, :$dryrun)

Use openssl to compute a sha256 hash

### sub curl-fetch($url, $file, :$verbose, :$dryrun)

Use curl to download a file from a url

### sub compile($src, :$obj, \*%args)

Compile a single source file with the right compiler. Can override
defaults with params :cc, :cxx, :cflags, :cxxflags, :extra-cxxflags,
:ccswitch, :ccout or the usual :verbose or :dryrun. Returns the path
to the compiled object.

### sub link($lib, @obj, :$dir = "resources/libraries", :$cpp, \*%args)

Link objects into a shared library, defaulting to the
`resources/libraries` directory. The library name is mangled to match
the system (e.g. `.so`, `.dylib`, `.dll`). Set the :cpp flag to foce
use of the C++ to link so symbols will work right. Can override
defaults with params :cxxld, :ld, :ldflags, :extra-ldflags, :ldshared,
:ldout or the usual :verbose or :dryrun

### sub fetch( :$lib, :$url, :$hash, :$dir = "resources/libraries", \*%args)

Fetch a library from a URL, name mangle the library and install into
resources/libraries by default, pass in :verbose or :dryrun as usual

### sub fallback($lib, @fallback, \*%args)

Process a list of fallback library fetching alternatives, each
possibly with an os/version, a url for the library, and a sha256 hash
for the library.

### sub build(:$lib, :@src, :@fallback, :$clean, :$dir, \*%args)

Build a library from sources in directory :dir compile each source
file, then link. Pass in :clean to remove objects after linking. Other
named parameters passed in are forwarded to the
compiler/linker. Additionally a fallback list will be processed on any
error if present.

### sub MAIN(Str :$dir = ".", Bool :n(:$dryrun), Bool :v(:$verbose))

For command line building

# LICENSE

This work is subject to the Artistic License 2.0.


## dist_cpan-GDONALD-Console-Blackjack.md
# Console-Blackjack

Console Blackjack written in Raku

## Features

* Alternate Deck Types
* Variable Number of Decks
* Hand Splitting
* Vegas-style Dealer Play (Dealer hits on soft 16)
* Options Saving

## Install using zef:

```
zef install Console::Blackjack

```

## Run

```
console-blackjack

```

## Increase your terminal font size for a better view:

![Blackjack](https://raw.githubusercontent.com/gdonald/Console-Blackjack/master/ss1.png)

![Blackjack](https://raw.githubusercontent.com/gdonald/Console-Blackjack/master/ss2.png)

## From source

If you've cloned the git repository you can run it like this:

```
raku -Ilib bin/console-blackjack

```

## Status

[![.github/workflows/raku.yml](https://github.com/gdonald/Console-Blackjack/workflows/.github/workflows/raku.yml/badge.svg)](https://github.com/gdonald/Console-Blackjack/actions)

## Bugs / Issues / Feature Requests

<https://github.com/gdonald/Console-Blackjack/issues>

## License

[![GitHub](https://img.shields.io/github/license/gdonald/Console-Blackjack?color=aa0000)](https://github.com/gdonald/Console-Blackjack/blob/master/LICENSE)

## Alternative Implementations:

I've written Blackjack in several other languages:

* [Ruby](https://github.com/gdonald/console-blackjack-ruby)
* [Rust](https://github.com/gdonald/console-blackjack-rust)
* [Typescript](https://github.com/gdonald/blackjack-js)
* [Perl](https://github.com/gdonald/console-blackjack-perl)
* [C](https://github.com/gdonald/blackjack-c)
* [C++](https://github.com/gdonald/blackjack-cpp)
* [Crystal](https://github.com/gdonald/blackjack-cr)
* [Go](https://github.com/gdonald/blackjack-go)
* [Elixir](https://github.com/gdonald/blackjack-ex)
* [Python](https://github.com/gdonald/blackjack-py)
* [C with SDL](https://github.com/gdonald/blackjack-c-sdl)
* [Emacs Lisp](https://github.com/gdonald/blackjack-el)


## dist_cpan-GARLANDG-Cro-H.md
[![Build Status](https://travis-ci.org/Garland-g/Cro-H.svg?branch=master)](https://travis-ci.org/Garland-g/Cro-H)

# NAME

Cro::H - A low-level component to interconnect two Cro pipelines

# SYNOPSIS

```
#These classes are stubbed
use Cro::H;
my $h-pipe = Cro::H.new;

my $pipeline1 = Cro.compose(Cro::Source, $h-pipe, Cro::Sink)
my $pipeline2 = Cro.compose(Cro::Source, $h-pipe, Cro::Sink)

($pipeline1, $pipeline2)>>.start;
#Both sinks will receive all the values from both sources

```

# DESCRIPTION

Cro::H is a way to interconnect two pipelines without needing to terminate either pipeline.

Split off a second pipelines by creating a source that outputs nothing as the start of the second pipeline.

Merge two pipelines by creating a sink that ignores all incoming values as the end of the second pipeline.

```
Sample pipeline:
 ---------      _________________      -------
| Source1 | -> |______     ______| -> | Sink1 |
 ---------            |   |           -------
                      | H |
 ---------      ______|   |______      -------
| Source2 | -> |_________________| -> | Sink2 |
 ---------                             -------

```

# AUTHOR

Travis Gibson [TGib.Travis@protonmail.com](mailto:TGib.Travis@protonmail.com)

# COPYRIGHT AND LICENSE

Copyright 2018 Travis Gibson

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-raku-community-modules-Grammar-Modelica.md
[![Actions Status](https://github.com/raku-community-modules/Grammar-Modelica/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/Grammar-Modelica/actions) [![Actions Status](https://github.com/raku-community-modules/Grammar-Modelica/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/Grammar-Modelica/actions) [![Actions Status](https://github.com/raku-community-modules/Grammar-Modelica/actions/workflows/windows.yml/badge.svg)](https://github.com/raku-community-modules/Grammar-Modelica/actions)

# NAME

Grammar::Modelica - A Grammar for the Modelica programming language

# SYNOPSIS

```
use Grammar::Modelica;

```

# DESCRIPTION

A Raku Grammar for the [Modelica Language Specification 3.4](https://www.modelica.org/documents/ModelicaSpec34.pdf) (pdf).

The Grammar is mostly a direct translation of the concrete syntax specification found in Appendix B.

See the test files to get some idea of what is going on.

# TODO

* make use of proto and more named parameters to make it more useful
* more stuff by and by

# AUTHOR

Steven Albano

# COPYRIGHT AND LICENSE

Copyright 2017 - 2018 Steven Albano

Copyright 2024 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-bduggan-App-termie.md
# termie

A console for your console

[![SparrowCI](https://ci.sparrowhub.io/project/gh-bduggan-termie/badge)](https://ci.sparrowhub.io)

![image](https://user-images.githubusercontent.com/58956/89128554-6e741000-d4c4-11ea-846a-32189f23900c.png)

## Description

termie (formerly tmeta) is a wrapper for tmux that supports
sending and receiving data to/from tmux panes.

Anything typed into the bottom pane is sent to the top one, but
lines that start with a backslash are commands for `termie`.
You can type `\help` to see all possible commands.

(To send a literal leading backslash, either start with a
space or start with a double backslash.)

## Why

Because you get:

* an uncluttered view of your commands separate from the output
* a local history for commands that are run remotely
* readline interface independent of the remote console
* scripting support for programs that require a TTY
* macros
* the ability to monitor or capture output
* other `expect`-like functionality
* controlled copy-and-paste operations into remote sessions

## Quick start

See below for installation.

There are a few different ways to start `termie`.

1. Start `tmux` yourself, then have `termie` split a window and
   start up in its own pane:

   ```
   $ tmux
   $ termie

   ```
2. Let `termie` start tmux for you:

```
$ termie

```

1. Run a termie script. This will split and run in another pane.

   ```
   $ tmux
   $ termie script.termie

   ```

I use the `.termie` suffix for my `termie` scripts. If you do too, you
might like this [vim syntax file](syntax/termie.vim).

## What do I use it with

termie plays well with REPLs, or any console based
application that uses a tty. For instance, docker, rails
console, interactive ruby shell, the python debugger, the
jupyter console, psql, mysql, regular ssh sessions, local
terminal sessions, whatever

## More documentation

Please see the [documentation](https://github.com/bduggan/tmeta/blob/master/doc.md) for a complete list of commands.

## Examples

Show a list of commands.

```
> \help

```

Run `date` every 5 seconds until the output contains `02`

```
> date
> \repeat
> \await 02

```

Within a debugger session, send `next` every 2 seconds.

```
> next
> \repeat 2

```

Search the command history for the last occurrence of 'User' using [fzf](https://github.com/junegunn/fzf)
(readline command history works too)

```
> \find User

```

Search the output for "http"

```
> \grep http

```

Send a local file named `bigfile.rb` to a remote rails console

```
> \send bigfile.rb

```

Same thing, but throttle the copy-paste operation, sending 1 line per second:

```
> \delay 1
> \send bigfile.rb

```

Similar, but send it to an ssh console by first tarring and base64 encoding
and not echoing stdout, and note that 'something' can also be a directory:

```
> \xfer something

```

Run a command locally, sending each line of output to the remote console:

```
> \do echo date

```

Run a shell snippet locally, sending each line of output to the remote console:

```
> \dosh for i in `seq 5`; do echo "ping host-$i"; done

```

Start printing the numbers 1 through 100, one per second, but send a ctrl-c
when the number 10 is printed:

```
> \enq \stop
queue is now : \stop
> for i in `seq 100`; do echo $i; sleep 1; done
# .. starts running in other pane ...
> \await 10
Waiting for "10"
Then I will send:
\stop
Done: saw "10"
starting enqueued command: \stop

```

Add an alias `cat` which cats a local file

```
\alias cat \shell cat

```

Show a local file (do not send it to the other pane) using the above alias

```
\cat myfile

```

Edit a file named session.rb, in ~/.termie/scripts

```
\edit session.rb

```

After running the above, add this to session.rb:

```
irb

\expect irb(main):001:0>

"hello world"

\expect irb(main):002:0>

exit

```

Now running

```
\run session.rb

```

will start the interactive ruby console (irb) and the following
session should take place on the top panel:

```
$ irb
irb(main):001:0> "hello world"
=> "hello world"
irb(main):002:0> exit
$

```

## Installation

Prerequisites: fzf, tmux, libreadline, raku and a few modules

1. Install a recent version of Raku. The recommended way is to use [rakubrew](https://rakubrew.org).
2. Also install `zef`, the Raku package manager (`rakubrew build-zef`)
3. Install [fzf](https://github.com/junegunn/fzf) and [tmux](https://github.com/tmux/tmux/wiki).
   (e.g. `brew install fzf tmux` on os/x)
4. zef install <https://github.com/bduggan/termie.git>

## See also

* The [documentation](https://github.com/bduggan/termie/blob/master/doc.md), with links to the source
* The same [documentation](https://github.com/bduggan/termie/blob/master/help.md) as shown by the `\help` command
* This blog article: <https://blog.matatu.org/raku-tmeta>


## dist_zef-jonathanstowe-Audio-Sndfile.md
# Audio::Sndfile

Binding to libsndfile ( <http://www.mega-nerd.com/libsndfile/> )

[![CI](https://github.com/jonathanstowe/Audio-Sndfile/actions/workflows/main.yml/badge.svg)](https://github.com/jonathanstowe/Audio-Sndfile/actions/workflows/main.yml)

## Description

This library provides a mechanism to read and write audio data files in
various formats by using the API provided by libsndfile.

A full list of the formats it is able to work with can be found at:

<http://www.mega-nerd.com/libsndfile/#Features>

if you need to work with formats that aren't listed then you will need to
find another library.

The interface presented is slightly simplified with regard to that of
libsndfile and whilst it does nearly everything I need it do, I have opted
to release the most useful functionality early and progressively add
features as it becomes clear how they should be implemented.

The "examples" directory in the repository contains some sample code that
may be useful or indicate how you might achieve a particular task.

The full documentation is available as [Markdown](Documentation.md) or
as POD withing the module file.

## Installation

You will need to have "libsndfile" installed on your system in order to
be able to use this. Most Linux distributions offer it as a package, though
it is such a common dependency for multimedia applications that you may well
already have it installed.

If you are on some platform that doesn't provide libsndfile as a package
then you may be able to install it from source:

<http://www.mega-nerd.com/libsndfile/#Download>

I am however unlikely to be able to offer help with installing it this way.

Assuming you have a working Rakudo installation you should be able to install this with *zef* :

```
# From the source directory

zef install .

# Remote installation

zef install Audio::Sndfile

```

## Support

Suggestions/patches are welcomed via github at

<https://github.com/jonathanstowe/Audio-Sndfile/issues>

There are several things that I know don't work properly at the time of the
first release:

```
* May not work at all or be unstable on 32 bit systems
  ( This is because data that references the number of frames is
    native sized within libsndfile - when I have worked out how to
    do the equivalent of a conditional typedef I'll fix this .)

```

Also I'd prefer to keep features that aren't directly related to those
provided by libsndfile separate, so if you want to manipulate the data,
play the data to some audio device or stream it for instance you probably
want to consider making a new module.

## Licence

This is free software.

Please see the <LICENCE> file in the distribution.

© Jonathan Stowe 2015 - 2024


## dist_zef-raku-community-modules-Template-Mojo.md
[![Actions Status](https://github.com/raku-community-modules/Template-Mojo/actions/workflows/test.yml/badge.svg)](https://github.com/raku-community-modules/Template-Mojo/actions)

# TITLE

class Template::Mojo

A templating system modeled after the Perl's <https://metacpan.org/module/Mojo::Template>

# SYNOPSIS

```
my $tmpl = slurp 'eg/template.tm';

my $t = Template::Mojo.new($tmpl);
$t.render()

my $ot = Template::Mojo.from-file('eg/template.tm');

```

# EXAMPLES

## Loop

### Template

```
% for 1..3 {
    hello
% }

```

### Code

```
my $tmpl = slurp 'eg/template.tm';
my $t = Template::Mojo.new($tmpl);
$t.render()

```

### Output

```
hello
hello
hello

```

## Parameters

### Template

```
% my ($x) = @_;

<%= $x %>

% for 1..$x {
    hello
% }

```

See, on the first row of the template we accept a parameter as if this was a generic function call. Then we use the veriable in two different ways.

### Code

The value to that subroutione can be passed in the render call:

```
my $tmpl = slurp 'eg/template.tm';
my $t = Template::Mojo.new($tmpl);
$t.render(5)

```

### Output:

```
5

    hello
    hello
    hello
    hello
    hello

```

## Passing hash

### Template

```
% my ($x) = @_;

Fname: <%= $x<fname> %>
Lname: <%= $x<lname> %>

```

### Code

```
my %params = (
  fname => 'Foo',
  lname => 'Bar',
);

my $tmpl = slurp 'eg/template.tm';
my $t = Template::Mojo.new($tmpl);
$t.render(%params)

```

### Output

```
Fname: Foo
Lname: Bar

```

## Complex examples

### Template

```
% my (%h) = @_;

<h1><%= %h<title> %>

<ul>
% for %h<pages>.values -> $p {
  <li><a href="<%= $p<url> %>"><%= $p<title> %></a></li>
% }
</ul>

```

### Code

```
my %params = (
   title => "Perl 6 Links",
   pages => [
      {
        "title" => "Rakudo",
        "url"   => "http://rakudo.org/",
      },
      {
        title   => 'Perl 6',
        url     => 'http://perl6.org/',
      }
   ],
);

my $tmpl = slurp 'eg/template.tm';
my $t = Template::Mojo.new($tmpl);
$t.render(%params)

```

### Output

```
<h1>Perl 6 Links

<ul>
  <li><a href="http://rakudo.org/">Rakudo</a></li>
  <li><a href="http://perl6.org/">Perl 6</a></li>
</ul>

```

# AUTHOR

Tadeusz “tadzik” Sośnierz"

# COPYRIGHT AND LICENSE

Copyright 2012-2017 Tadeusz Sośnierz Copyright 2023 Raku Community

This library is free software; you can redistribute it and/or modify it under the MIT license.

Please see the LICENCE file in the distribution

# CONTRIBUTORS

* Andrew Egeler
* Anthony Parsons
* Carl Masak
* Gabor Szabo
* Moritz Lenz
* Sterling Hanenkamp
* Timo Paulssen
* Tobias Leich


## w.md
w

Combined from primary sources listed below.

# [In IO::Special](#___top "go to top of document")[§](#(IO::Special)_method_w "direct link")

See primary documentation
[in context](/type/IO/Special#method_w)
for **method w**.

```raku
method w(IO::Special:D: --> Bool)
```

The 'write access' file test operator, returns `True` only if this instance represents either the standard output (`<STOUT>`) or the standard error (`<STDERR>`) handle.

# [In Proc::Async](#___top "go to top of document")[§](#(Proc::Async)_method_w "direct link")

See primary documentation
[in context](/type/Proc/Async#method_w)
for **method w**.

```raku
method w(Proc::Async:D:)
```

Returns a true value if `:w` was passed to the constructor, that is, if the external program is started with its input stream made available to output to the program through the `.print`, `.say` and `.write` methods.

# [In IO::Path](#___top "go to top of document")[§](#(IO::Path)_method_w "direct link")

See primary documentation
[in context](/type/IO/Path#method_w)
for **method w**.

```raku
method w(IO::Path:D: --> Bool:D)
```

Returns `True` if the invocant is a path that exists and is writable. The method will [`fail`](/routine/fail) with [`X::IO::DoesNotExist`](/type/X/IO/DoesNotExist) if the path points to a non-existent filesystem entity.


## dist_zef-antononcube-ML-NLPTemplateEngine.md
# ML::NLPTemplateEngine

This Raku package aims to create (nearly) executable code for various computational workflows.

Package's data and implementation make a Natural Language Processing (NLP)
[Template Engine (TE)](https://en.wikipedia.org/wiki/Template_processor), [Wk1],
that incorporates
[Question Answering Systems (QAS')](https://en.wikipedia.org/wiki/Question_answering), [Wk2],
and Machine Learning (ML) classifiers.

The current version of the NLP-TE of the package heavily relies on Large Language Models (LLMs) for its QAS component.

Future plans involve incorporating other types of QAS implementations.

The Raku package implementation closely follows the Wolfram Language (WL) implementations in
["NLP Template Engine"](https://github.com/antononcube/NLP-Template-Engine), [AAr1, AAv1],
and the WL paclet
["NLPTemplateEngine"](https://resources.wolframcloud.com/PacletRepository/resources/AntonAntonov/NLPTemplateEngine/), [AAp2, AAv2].

An alternative, more comprehensive approach to building workflows code is given in [AAp2].

### Problem formulation

We want to have a system (i.e. TE) that:

1. Generates relevant, correct, executable programming code based on natural language specifications of computational
   workflows
2. Can automatically recognize the workflow types
3. Can generate code for different programming languages and related software packages

The points above are given in order of importance; the most important are placed first.

### Reliability of results

One of the main reasons to re-implement the WL NLP-TE, [AAr1, AAp1], into Raku is to have a more robust way
of utilizing LLMs to generate code. That goal is more or less achieved with this package, but
YMMV -- if incomplete or wrong results are obtained run the NLP-TE with different LLM parameter settings
or different LLMs.

---

## Installation

From Zef ecosystem:

```
zef install ML::NLPTemplateEngine;

```

From GitHub:

```
zef install https://github.com/antononcube/Raku-ML-NLPTemplateEngine.git

```

---

## Usage examples

### Quantile Regression (WL)

Here the template is automatically determined:

```
use ML::NLPTemplateEngine;

my $qrCommand = q:to/END/;
Compute quantile regression with probabilities 0.4 and 0.6, with interpolation order 2, for the dataset dfTempBoston.
END

concretize($qrCommand);

```

```
# qrObj=
# QRMonUnit[dfTempBoston]⟹
# QRMonEchoDataSummary[]⟹
# QRMonQuantileRegression[12, {0.4, 0.6}, InterpolationOrder->2]⟹
# QRMonPlot["DateListPlot"->True,PlotTheme->"Detailed"]⟹
# QRMonErrorPlots["RelativeErrors"->False,"DateListPlot"->True,PlotTheme->"Detailed"];

```

**Remark:** In the code above the template type, "QuantileRegression", was determined using an LLM-based classifier.

### Latent Semantic Analysis (R)

```
my $lsaCommand = q:to/END/;
Extract 20 topics from the text corpus aAbstracts using the method NNMF.
Show statistical thesaurus with the words neural, function, and notebook.
END

concretize($lsaCommand, template => 'LatentSemanticAnalysis', lang => 'R');

```

```
# lsaObj <-
# LSAMonUnit(aAbstracts) %>%
# LSAMonMakeDocumentTermMatrix(stemWordsQ = Automatic, stopWords = Automatic) %>%
# LSAMonEchoDocumentTermMatrixStatistics(logBase = 10) %>%
# LSAMonApplyTermWeightFunctions(globalWeightFunction = "IDF", localWeightFunction = "None", normalizerFunction = "Cosine") %>%
# LSAMonExtractTopics(numberOfTopics = 20, method = "NNMF", maxSteps = 16, minNumberOfDocumentsPerTerm = 20) %>%
# LSAMonEchoTopicsTable(numberOfTerms = 10, wideFormQ = TRUE) %>%
# LSAMonEchoStatisticalThesaurus(words = c("neural", "function", "notebook"))

```

### Random tabular data generation (Raku)

```
my $command = q:to/END/;
Make random table with 6 rows and 4 columns with the names <A1 B2 C3 D4>.
END

concretize($command, template => 'RandomTabularDataset', lang => 'Raku', llm => 'gemini');

```

```
# random-tabular-dataset(6, 4, "column-names-generator" => <A1 B2 C3 D4>, "form" => "Table", "max-number-of-values" => 24, "min-number-of-values" => 24, "row-names" => False)

```

**Remark:** In the code above it was specified to use Google's Gemini LLM service.

---

## CLI

The package provides the Command Line Interface (CLI) script `concretize`. Here is usage note:

```
concretize --help

```

```
# Usage:
#   concretize [<words> ...] [-t|--template=<Str>] [-l|--to|--lang=<Str>] [-c|--clipboard-command=<Str>] [--<args>=...]
#
#     -t|--template=<Str>             Template to use. [default: 'Whatever']
#     -l|--to|--lang=<Str>            Template's language. [default: 'R']
#     -c|--clipboard-command=<Str>    Clipboard command to use. [default: 'Whatever']
#     --<args>=...                    Additional arguments for &ML::FindTextualAnswer::find-textual-answer.

```

---

## How it works?

The following flowchart describes how the NLP Template Engine involves a series of steps for processing a computation
specification and executing code to obtain results:

```
flowchart TD
  spec[/Computation spec/] --> workSpecQ{"Is workflow type<br>specified?"}
  workSpecQ --> |No| guess[[Guess relevant<br>workflow type]]
  workSpecQ -->|Yes| raw[Get raw answers]
  guess -.- classifier[[Classifier:<br>text to workflow type]]
  guess --> raw
  raw --> process[Process raw answers]
  process --> template[Complete<br>computation<br>template]
  template --> execute[/Executable code/]
  execute --> results[/Computation results/]

  llm{{LLM}} -.- find[[find-textual-answer]]
  llm -.- classifier
  subgraph LLM-based functionalities
    classifier
    find
  end

  find --> raw
  raw --> find
  template -.- compData[(Computation<br>templates<br>data)]
  compData -.- process

  classDef highlighted fill:Salmon,stroke:Coral,stroke-width:2px;
  class spec,results highlighted

```

Here's a detailed narration of the process:

1. **Computation Specification**:

   * The process begins with a "Computation spec", which is the initial input defining the requirements or parameters
     for the computation task.
2. **Workflow Type Decision**:

   * A decision node asks if the workflow type is specified.
3. **Guess Workflow Type**:

   * If the workflow type is not specified, the system utilizes a classifier to guess relevant workflow type.
4. **Raw Answers**:

   * Regardless of how the workflow type is determined (directly specified or guessed), the system retrieves "raw
     answers", crucial for further processing.
5. **Processing and Templating**:

   * The raw answers undergo processing ("Process raw answers") to organize or refine the data into a usable format.
   * Processed data is then utilized to "Complete computation template", preparing for executable operations.
6. **Executable Code and Results**:

   * The computation template is transformed into "Executable code", which when run, produces the final "Computation
     results".
7. **LLM-Based Functionalities**:

   * The classifier and the answers finder are LLM-based.
8. **Data and Templates**:

   * Code templates are selected based on the specifics of the initial spec and the processed data.

---

## Bring your own templates

**0.** Load the NLP-Template-Engine package (and others):

```
use ML::NLPTemplateEngine;
use Data::Importers;
use Data::Summarizers;

```

```
# (Any)

```

**1.** Get the "training" templates data (from CSV file you have created or changed) for a new workflow
(["SendMail"](https://github.com/antononcube/NLP-Template-Engine/blob/main/TemplateData/dsQASParameters-SendMail.csv)):

```
my $url = 'https://raw.githubusercontent.com/antononcube/NLP-Template-Engine/main/TemplateData/dsQASParameters-SendMail.csv';
my @dsSendMail = data-import($url, headers => 'auto');

records-summary(@dsSendMail, field-names => <DataType WorkflowType Group Key Value>);

```

```
# +-----------------+----------------+-----------------------------+----------------------------+----------------------------------------------------------------------------------+
# | DataType        | WorkflowType   | Group                       | Key                        | Value                                                                            |
# +-----------------+----------------+-----------------------------+----------------------------+----------------------------------------------------------------------------------+
# | Questions => 48 | SendMail => 60 | All                   => 9  | TypePattern          => 12 | 0.35                                                                       => 9  |
# | Defaults  => 7  |                | What it the content   => 4  | Parameter            => 12 | {_String..}                                                                => 8  |
# | Templates => 3  |                | What it the title     => 4  | ContextWordsToRemove => 12 | _String                                                                    => 4  |
# | Shortcuts => 2  |                | Who the email is from => 4  | Threshold            => 12 | {"to", "email", "mail", "send", "it", "recipient", "addressee", "address"} => 4  |
# |                 |                | Which files to attach => 4  | Template             => 3  | None                                                                       => 4  |
# |                 |                | What it the body      => 4  | attachedFiles        => 1  | to                                                                         => 4  |
# |                 |                | What subject          => 4  | SendMail             => 1  | body                                                                       => 3  |
# |                 |                | (Other)               => 27 | (Other)              => 7  | (Other)                                                                    => 24 |
# +-----------------+----------------+-----------------------------+----------------------------+----------------------------------------------------------------------------------+

```

**2.** Add the ingested data for the new workflow (from the CSV file) into the NLP-Template-Engine:

```
add-template-data(@dsSendMail);

```

```
# (Templates Defaults ParameterQuestions ParameterTypePatterns Questions Shortcuts)

```

**3.** Parse natural language specification with the newly ingested and onboarded workflow ("SendMail"):

```
"Send email to joedoe@gmail.com with content RandomReal[343], and the subject this is a random real call."
        ==> concretize(template => "SendMail")

```

```
# SendMail[<|"To"->{"joedoe@gmail.com"},"Subject"->"this is a random real call.","Body"->RandomReal[343],"AttachedFiles"->None|>]

```

**4.** Experiment with running the generated code!

---

## TODO

* Templates data
  * Using JSON instead of CSV format for the templates
    * Derive suitable data structure
    * Implement export to JSON
    * Implement ingestion
  * Review wrong parameter type specifications
    * A few were found.
  * New workflows
    * LLM-workflows
    * Clustering
    * Associative rule learning
* Unit tests
  * What are good ./t unit tests?
  * Make ingestion ./t unit tests
  * Make suitable ./xt unit tests
* Documentation
  * Comparison with LLM code generation using few-shot examples
  * Video demonstrating the functionalities

---

## References

### Articles

[Wk1] Wikipedia entry, [Template processor](https://en.wikipedia.org/wiki/Template_processor).

[Wk2] Wikipedia entry, [Question answering](https://en.wikipedia.org/wiki/Question_answering).

### Functions, packages, repositories

[AAr1] Anton Antonov,
["NLP Template Engine"](https://github.com/antononcube/NLP-Template-Engine),
(2021-2022),
[GitHub/antononcube](https://github.com/antononcube).

[AAp1] Anton Antonov,
[NLPTemplateEngine WL paclet](https://resources.wolframcloud.com/PacletRepository/resources/AntonAntonov/NLPTemplateEngine/),
(2023),
[Wolfram Language Paclet Repository](https://resources.wolframcloud.com/PacletRepository/).

[AAp2] Anton Antonov,
[DSL::Translators Raku package](https://github.com/antononcube/Raku-DSL-Translators),
(2020-2024),
[GitHub/antononcube](https://github.com/antononcube).

[WRI1] Wolfram Research,
[FindTextualAnswer](https://reference.wolfram.com/language/ref/FindTextualAnswer.html),
(2018),
[Wolfram Language function](https://reference.wolfram.com), (updated 2020).

### Videos

[AAv1] Anton Antonov,
["NLP Template Engine, Part 1"](https://youtu.be/a6PvmZnvF9I),
(2021),
[YouTube/@AAA4Prediction](https://www.youtube.com/@AAA4Prediction).

[AAv2] Anton Antonov,
["Natural Language Processing Template Engine"](https://www.youtube.com/watch?v=IrIW9dB5sRM) presentation given at
WTC-2022,
(2023),
[YouTube/@Wolfram](https://www.youtube.com/@Wolfram).


## dist_zef-jonathanstowe-Util-Uuencode.md
# Util::Uuencode

uuencode/uudecode for Raku

![Build Status](https://github.com/jonathanstowe/Util-Uuencode/workflows/CI/badge.svg)

## Synopsis

use Util::Uuencode;

my $image = "some-image.jpg".IO.slurp(:bin);

my $encoded = uuencode($image);

# now $encoded can be sent or stored as text safely

$image = uudecode($encoded);

# now have the image back as binary

## Description

[uuencode](https://en.wikipedia.org/wiki/Uuencoding) is a binary to text encoding mechanism designed for sending binary files across computer boundaries where the transport mechanism may not be 8 bit clean, such as e-mail, usenet or uucp. It has largely been obsoleted by MIME (and Base64 encoding,) and the advent of ubiquitous 8 bit clean networking.

This module provides routines for uuencoding (`uuencode`) and decoding (`uudecode`) which will round trip data between binary and text encoded representations. `uuencode` will quite happily encode plain text but as the effect is to make it a third larger there isn't much point doing that ( I guess at a push it could be used to preserve some unicode encoding across some boundary that doesn't deal with that well.)

The POSIX commands [uuencode and uudecode](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/uuencode.html) expect some additional header and trailer information which this module doesn't deal with, so if you expect your data to be processed by these tools you will need to add this to your encoded output and remove it from the input for correct processing.

## Installation

Assuming you have a working Rakudo installation then this can be installed by `zef` :

```
zef install Util::Uuencode

# Or from a local clone

zef install .

```

There are no depenencies.

## Support

This is one of those things that either works or it doesn't but if you have a problem or suggestions please report them on [Github](https://github.com/jonathanstowe/Util-Uuencode/issues).

## Licence

This is free software.

Please see the <LICENCE> file in the distribution.

© Jonathan Stowe 2020


## dist_zef-raku-community-modules-LWP-Simple.md
# LWP::Simple for Raku

![Test Windows and MacOS](https://github.com/raku-community-modules/LWP-Simple/workflows/Test%20Windows%20and%20MacOS/badge.svg)

This is a quick & dirty implementation of a LWP::Simple clone for Raku; it does both `GET` and `POST` requests.

# Dependencies

LWP::Simple depends on the modules MIME::Base64 and URI,
which you can find at <http://modules.raku.org/>. The tests depends
on [JSON::Tiny](https://github.com/moritz/json).

Write:

```
zef install --deps-only .

```

You'll have to
install [IO::Socket::SSL](https://github.com/sergot/io-socket-ssl) via

```
zef install IO::Socket::SSL

```

if you want to work with `https` too.

# Synopsis

```
use LWP::Simple;

my $content = LWP::Simple.get("https://raku.org");

my $response = LWP::Simple.post("https://somewhere.topo.st", { so => True }

```

# Methods

## get ( $url, [ %headers = {}, Bool :$exception ] )

Sends a GET request to the value of `$url`. Returns the content of the return
request. Errors are ignored and will result in a `Nil` value unless
`$exception` is set to `True`, in which case an `LWP::Simple::Response` object
containing the status code and brief description of the error will be returned.

Requests are make with a default user agent of `LWP::Simple/$VERSION Raku/$*PERL.compiler.name()` which may get blocked by some web servers. Try
overriding the default user agent header by passing a user agent string to the
`%headers` argument with something like `{ 'User-Agent' => 'Your User-Agent String' }` if you have trouble getting content back.

# Current status

You can
use [HTTP::UserAgent](https://github.com/sergot/http-useragent)
instead, with more options. However, this module will do just fine in
most cases.

The documentation of this module is incomplete. Contributions are appreciated.

# Use

Use the installed commands:

```
 lwp-download.p6  http://eu.httpbin.org

```

Or

```
 lwp-download.p6  https://docs.perl6.org

```

If `ÌO::Socket::SSL` has been installed.

```
lwp-get.p6  https://raku.org

```

will instead print to standard output.

# Known bugs

According
to
[issues raised](https://github.com/raku-community-modules/LWP-Simple/issues/40),
[in this repo](https://github.com/raku-community-modules/LWP-Simple/issues/28),
there could be some issues with older versions of MacOSx. This issue
does not affect the functionality of the module, but just the test
script itself, so you can safely install with `--force`. Right now,
it's working correctly (as far as tests go) with Windows, MacOSx and
Linux.

# License

This distribution is licensed under the terms of
the
[Artistic 2.0 license](https://www.perlfoundation.org/artistic-license-20.html). You
can find a [copy](LICENSE) in the repository itself.


## one.md
one

Combined from primary sources listed below.

# [In Any](#___top "go to top of document")[§](#(Any)_method_one "direct link")

See primary documentation
[in context](/type/Any#method_one)
for **method one**.

```raku
method one(--> Junction:D)
```

Interprets the invocant as a list and creates a [one](/routine/one)-[`Junction`](/type/Junction) from it.

```raku
say so 1 == (1, 2, 3).one;      # OUTPUT: «True␤»
say so 1 == (1, 2, 1).one;      # OUTPUT: «False␤»
```


## dist_cpan-KAIEPI-Crypt-CAST5.md
[![Build Status](https://travis-ci.org/Kaiepi/p6-Crypt-CAST5.svg?branch=master)](https://travis-ci.org/Kaiepi/p6-Crypt-CAST5)

# NAME

Crypt::CAST5 - CAST5 encryption library

# SYNOPSIS

```
use Crypt::CAST5;

my Crypt::CAST5 $cast5   .= new: 'ayy lmao'.encode;
my Str          $in       = 'sup my dudes';
my Blob         $encoded  = $cast5.encode: $in.encode;
my Blob         $decoded  = $cast5.decode: $encoded;
my Str          $out      = $decoded.decode;

say $out; # OUTPUT: sup my dudes

```

# DESCRIPTION

**Warning: this implementation is naive and is not implemented in constant time, thus it is vulnerable to side channel attacks. Do not use this library for any serious applications as it stands now!**

Crypt::CAST5 is a library that handles encryption and decryption using the CAST5 algorithm. Currently, only the ECB block cipher mode is supported.

# METHODS

* **new**(Blob *$key*)

Constructs a new instance of Crypt::CAST5 using the given block cipher mode and key. The key must be 5-16 bytes in length.

* **encode**(Blob *$plaintext* --> Blob)

Encodes `$plaintext` using CAST5 encryption.

* **decode**(Blob *$ciphertext* --> Blob)

Decodes `$ciphertext` using CAST5 encryption.

# AUTHOR

Ben Davies (Kaiepi)

# COPYRIGHT AND LICENSE

Copyright 2018 Ben Davies

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-jonathanstowe-Audio-Libshout.md
# Audio::Libshout

Raku binding to libshout - provide icecast/streaming client

![Build Status](https://github.com/jonathanstowe/Audio-Libshout/workflows/CI/badge.svg)

## Synopsis

```
use v6;

use Audio::Libshout;

sub MAIN(IO(Str) $in-file) {
    my $shout = Audio::Libshout.new(password => 'hackme', mount => '/foo', format => Audio::Libshout::Format::MP3);
    my $fh = $in-file.open(:bin);
    my $channel = $shout.send-channel;

    while not $fh.eof {
        my $buf = $fh.read(4096);
        $channel.send($buf);
    }

    $fh.close;
    $channel.close;
    $shout.close;
}

```

## Description

This provides a source client to stream to an icecast server. It can
stream Ogg/Vorbis or MP3 data but doesn't provide any transcoding so the
data will need to be provided from an appropriate source in the required
encoding. This has been developed against version 2.2.2 of libshout,
it is possible later versions may provide support for other encodings.

The API is somewhat simplified in comparison to libshout but provides
an asynchronous mechanism whereby data can be fed as quickly as it is
obtained to a worker thread via a channel so the client doesn't have
to worry about the timing and synchronisation issues, though the lower
level send and sync methods are available if your application requires
a different scheme.

In testing this proved quite capable of streaming a 320kb/s MP3 read from
a file to an icecast server on the local network, though of course network
conditions may limit the rate that will work well to remote servers.

The "examples" directory in the distribution contains a simple streaming
source client that will allow you to send an Ogg or MP3 file to an
icecast server.

If you're curious the first thing that I streamed using this library was

<https://www.mixcloud.com/mikestern-awakening/mike-stern-guest-mix-for-technotic-eire-radio-show/>

Mike's a great DJ, great DJs and producers make making software
worthwhile :)

The full documentation is available as [markdown](Documentation.md) or embedded POD.

## Installation

You will need to have "libshout" installed on your system in order to
be able to use this. Most Linux distributions offer it as a package.

If you are on some platform that doesn't provide libshout as a package
then you may be able to install it from source:

<https://github.com/xiph/Icecast-libshout>

I am however unlikely to be able to offer help with installing it this way, also bear in mind that
if you install a newer version than I have to test with then this may not work.

In order to perform some of the tests you will need to have a working Icecast server available,
these tests will be skipped if one isn't found. The tests use some default values for the server
parameters that can be over-written by some environment variables:

* SHOUT\_TEST\_HOST - the host to connect to. The default is 'localhost'
* SHOUT\_TEST\_PORT - the port to connect to. The default is 8000.
* SHOUT\_TEST\_USER - the user to authenticate as. The default is 'source'.
* SHOUT\_TEST\_PASS - the password to authenticate with. The default is 'hackme' but you changed that right?
* SHOUT\_TEST\_MOUNT - the mount point on the server to use. The default is '/shout\_test'

Assuming you have a working Rakudo installation as well as a working icecast server you should be able to install this with *zef* :

```
# From the source directory

zef install .

# Remote installation

zef install Audio::Libshout

```

## Support

Suggestions/patches are welcomed via [github](https://github.com/jonathanstowe/Audio-Libshout)

I have tested this and found it to work with my installation of icecast,
so it should work anywhere else, if however you experience a problem
with streaming please test with another source client such as ices or
darkice before reporting a bug as I am unlikely to be able to help you
with your streaming configuration.

There are some small variations in the behaviour of `libshout` between
versions and these are documented where known in [the Documentation](Documentation.md) however please supply the `libshout` version if you find unexpected behaviour.

## Licence

Please see the <LICENCE> file in the distribution

© Jonathan Stowe 2015, 2016, 2017, 2019, 2020, 2021


## dist_github-colomon-Test-Junkie.md
# Test::Junkie

## Continuous test runner for Perl 6

Requires a recent version of Rakudo (after April 21st, 2012) for updates IO.pm
changetime detection. Currently depends on Perl 5 prove as a testrunner.

## Background

**junk·ie** *noun* \ˈjəŋ-kē\ - a person who derives inordinate pleasure from or who is dependent on something *(in this case testing)*

The initial version was developed as a part of the Perl 6 patterns hackathon in Oslo, and based on masak's mini-tote Gist for all functionality. See: <https://gist.github.com/834500>

##Planned extensions

* pluggable implementations for running tests
* pluggable implementations for reporting
* separate running from reporting
* option to 'make' before running tests in order to update blib/lib (should be useful for modules already installed


## dist_zef-thundergnat-String-Rotate.md
[![Actions Status](https://github.com/thundergnat/String-Rotate/actions/workflows/test.yml/badge.svg)](https://github.com/thundergnat/String-Rotate/actions)

# NAME

String::Rotate - Rotate, but for Strings directly instead of through Lists

# SYNOPSIS

```
use String::Rotate;

say 'Rakudo'.&rotate; # akudoR

say 'Rakudo'.&rotate(-1); # oRakud

say rotate 'Rakudo', 3; # udoRak

```

Also export a Role `Rotate` which may be used to augment strings

```
use String::Rotate;
use MONKEY-TYPING;

augment class Str does Rotate { }

say 'Rakudo'.rotate; # akudoR

say 'Rakudo'.rotate(-1); # oRakud

```

# DESCRIPTION

Rotate routine, but for Strings instead of Lists. Seems a little redundant at first glance, you could easily do `'Rakudo'.comb.list.rotate.join` for the same effect, but the purpose built routines are, at a minimum, twice as fast and may be tens or hundreds times faster for longer strings.

This routine takes a String, returns a String and only perform String operations. It runs in near constant time no matter how long the string is. `.comb.list.rotate.join` is heavily influenced by the size of the string.

# AUTHOR

thundergnat (Steve Schulze)

# COPYRIGHT AND LICENSE

Copyright 2020 thundergnat

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.