<commit_before>## $Id$

=head1 NAME

src/classes/List.pir - Perl 6 List class and related functions

=head1 Methods

=over 4

=cut

.namespace ['List']

.sub 'onload' :anon :load :init
    .local pmc p6meta, listproto
    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
    listproto = p6meta.'new_class'('List', 'parent'=>'ResizablePMCArray Any')
    p6meta.'register'('ResizablePMCArray', 'parent'=>'Any', 'protoobject'=>listproto)
.end


=item get_string()    (vtable method)

Return the elements of the list joined by spaces.

=cut

.sub 'get_string' :vtable :method
    $S0 = join ' ', self
    .return ($S0)
.end


=item clone()    (vtable method)

Clones the list.

=cut

.sub 'clone' :vtable :method
    $P0 = 'list'(self)
    .return ($P0)
.end


=item perl()

Returns a Perl representation of a List.

=cut

.sub 'perl' :method
    .local string res
    res .= '('

    .local pmc elem
    .local int elems
    .local int i

    elems = self.'elems'()
    i = 0

  loop:
    if i == elems goto done
    unless i  > 0 goto no_comma

    res .= ', '
  no_comma:
    elem = self[i]
    $S0 = elem
    res .= $S0

    i += 1
    goto loop


  done:
    res .= ')'
<commit_msg>[rakudo] List.perl should use square brackets. pmichaud++<commit_after>## $Id$

=head1 NAME

src/classes/List.pir - Perl 6 List class and related functions

=head1 Methods

=over 4

=cut

.namespace ['List']

.sub 'onload' :anon :load :init
    .local pmc p6meta, listproto
    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
    listproto = p6meta.'new_class'('List', 'parent'=>'ResizablePMCArray Any')
    p6meta.'register'('ResizablePMCArray', 'parent'=>'Any', 'protoobject'=>listproto)
.end


=item get_string()    (vtable method)

Return the elements of the list joined by spaces.

=cut

.sub 'get_string' :vtable :method
    $S0 = join ' ', self
    .return ($S0)
.end


=item clone()    (vtable method)

Clones the list.

=cut

.sub 'clone' :vtable :method
    $P0 = 'list'(self)
    .return ($P0)
.end


=item perl()

Returns a Perl representation of a List.

=cut

.sub 'perl' :method
    .local string res
    res .= '['

    .local pmc elem
    .local int elems
    .local int i

    elems = self.'elems'()
    i = 0

  loop:
    if i == elems goto done
    unless i  > 0 goto no_comma

    res .= ', '
  no_comma:
    elem = self[i]
    $S0 = elem
    res .= $S0

    i += 1
    goto loop


  done:
    res .= ']'

{'fraction_non_alphanumeric': 0.1423841059602649, 'fraction_numerical': 0.015728476821192054, 'mean_word_length': 2.6676783004552354, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7180498', 'n_tokens_mistral': 951, 'n_tokens_neox': 906, 'n_words': 278}