<commit_before>-module('clojerl.Vector').

-include("clojerl.hrl").

-behavior('clojerl.Counted').
-behavior('clojerl.IColl').
-behavior('clojerl.IEquiv').
-behavior('clojerl.IFn').
-behavior('clojerl.IMeta').
-behavior('clojerl.Indexed').
-behavior('clojerl.ISequential').
-behavior('clojerl.IStack').
-behavior('clojerl.Seqable').
-behavior('clojerl.Stringable').

-export([new/1, subvec/3]).

-export(['clojerl.Counted.count'/1]).
-export([ 'clojerl.IColl.cons'/2
        , 'clojerl.IColl.empty'/1
        ]).
-export([ 'clojerl.IEquiv.equiv'/2]).
-export(['clojerl.IFn.invoke'/2]).
-export([ 'clojerl.IMeta.meta'/1
        , 'clojerl.IMeta.with_meta'/2
        ]).
-export(['clojerl.ISequential.noop'/1]).
-export([ 'clojerl.Indexed.nth'/2
        , 'clojerl.Indexed.nth'/3
        ]).
-export([ 'clojerl.IStack.peek'/1
        , 'clojerl.IStack.pop'/1
        ]).
-export(['clojerl.Seqable.seq'/1]).
-export(['clojerl.Stringable.str'/1]).

-type type() :: #?TYPE{}.

-spec new(list()) -> type().
new(Items) when is_list(Items) ->
  #?TYPE{data = array:from_list(Items, none)}.

-spec subvec(type(), integer(), integer()) -> type().
subvec(Vector, Start, End) ->
  AddItemAtFun =
    fun(Index, Subvec) ->
        'clojerl.IColl.cons'(Subvec, 'clojerl.Indexed.nth'(Vector, Index))
    end,
  lists:foldl(AddItemAtFun, new([]), lists:seq(Start, End)).

%%------------------------------------------------------------------------------
%% Protocols
%%------------------------------------------------------------------------------

'clojerl.Counted.count'(#?TYPE{name = ?M, data = Array}) -> array:size(Array).

'clojerl.IColl.cons'(#?TYPE{name = ?M, data = Array} = Vector, X) ->
  NewArray = array:set(array:size(Array), X, Array),<commit_msg>[#130] Update default value for internal representation of vectors<commit_after>-module('clojerl.Vector').

-include("clojerl.hrl").

-behavior('clojerl.Counted').
-behavior('clojerl.IColl').
-behavior('clojerl.IEquiv').
-behavior('clojerl.IFn').
-behavior('clojerl.IMeta').
-behavior('clojerl.Indexed').
-behavior('clojerl.ISequential').
-behavior('clojerl.IStack').
-behavior('clojerl.Seqable').
-behavior('clojerl.Stringable').

-export([new/1, subvec/3]).

-export(['clojerl.Counted.count'/1]).
-export([ 'clojerl.IColl.cons'/2
        , 'clojerl.IColl.empty'/1
        ]).
-export([ 'clojerl.IEquiv.equiv'/2]).
-export(['clojerl.IFn.invoke'/2]).
-export([ 'clojerl.IMeta.meta'/1
        , 'clojerl.IMeta.with_meta'/2
        ]).
-export(['clojerl.ISequential.noop'/1]).
-export([ 'clojerl.Indexed.nth'/2
        , 'clojerl.Indexed.nth'/3
        ]).
-export([ 'clojerl.IStack.peek'/1
        , 'clojerl.IStack.pop'/1
        ]).
-export(['clojerl.Seqable.seq'/1]).
-export(['clojerl.Stringable.str'/1]).

-type type() :: #?TYPE{}.

-spec new(list()) -> type().
new(Items) when is_list(Items) ->
  #?TYPE{data = array:from_list(Items, undefined)}.

-spec subvec(type(), integer(), integer()) -> type().
subvec(Vector, Start, End) ->
  AddItemAtFun =
    fun(Index, Subvec) ->
        'clojerl.IColl.cons'(Subvec, 'clojerl.Indexed.nth'(Vector, Index))
    end,
  lists:foldl(AddItemAtFun, new([]), lists:seq(Start, End)).

%%------------------------------------------------------------------------------
%% Protocols
%%------------------------------------------------------------------------------

'clojerl.Counted.count'(#?TYPE{name = ?M, data = Array}) -> array:size(Array).

'clojerl.IColl.cons'(#?TYPE{name = ?M, data = Array} = Vector, X) ->
  NewArray = array:set(array:size(Array), X, Array),
{'fraction_non_alphanumeric': 0.3012965050732807, 'fraction_numerical': 0.009864712514092447, 'mean_word_length': 2.617737003058104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '1997063', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1272, 'n_words': 167}