<commit_before>-module('clojerl.erlang.Tuple').

-behavior('clojerl.Counted').
-behavior('clojerl.IHash').
-behavior('clojerl.ISequential').
-behavior('clojerl.Seqable').
-behavior('clojerl.Stringable').

-export([count/1]).
-export([hash/1]).
-export(['_'/1]).
-export([seq/1]).
-export([str/1]).

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

count(Tuple) -> tuple_size(Tuple).

hash(Tuple) -> clj_murmur3:ordered(Tuple).

'_'(_) -> undefined.

seq({}) -> undefined;
seq(Tuple) -> tuple_to_list(Tuple).

str(Tuple) when is_tuple(Tuple) ->
  Items     = tuple_to_list(Tuple),
  ItemsStrs = lists:map(fun clj_core:str/1, Items),
  Strs      = 'clojerl.String':join(ItemsStrs, <<", ">>),
  <<"#[", Strs/binary, "]">>.<commit_msg>[#102] Add clojerl.Indexed implementation to Tuple<commit_after>-module('clojerl.erlang.Tuple').

-behavior('clojerl.Counted').
-behavior('clojerl.IHash').
-behavior('clojerl.ISequential').
-behavior('clojerl.Indexed').
-behavior('clojerl.Seqable').
-behavior('clojerl.Stringable').

-export([count/1]).
-export([hash/1]).
-export(['_'/1]).
-export([ nth/2
        , nth/3
        ]).
-export([seq/1]).
-export([str/1]).

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

count(Tuple) -> tuple_size(Tuple).

hash(Tuple) -> clj_murmur3:ordered(Tuple).

'_'(_) -> undefined.

nth(Tuple, N) ->
  erlang:element(N + 1, Tuple).

nth(Tuple, N, NotFound) ->
  case N >= erlang:size(Tuple) of
    true  -> NotFound;
    false -> erlang:element(N + 1, Tuple)
  end.

seq({}) -> undefined;
seq(Tuple) -> tuple_to_list(Tuple).

str(Tuple) when is_tuple(Tuple) ->
  Items     = tuple_to_list(Tuple),
  ItemsStrs = lists:map(fun clj_core:str/1, Items),
  Strs      = 'clojerl.String':join(ItemsStrs, <<", ">>),
  <<"#[", Strs/binary, "]">>.
{'fraction_non_alphanumeric': 0.3545499751367479, 'fraction_numerical': 0.0104425658876181, 'mean_word_length': 2.138845553822153, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 28, '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': '5619942', 'n_tokens_mistral': 722, 'n_tokens_neox': 678, 'n_words': 94}