<commit_before>use v6;

# NOTE: Experimenting with documentation for tutorials / help

# P21 (*) Insert an element at a given position into a list.
# 
# Example:
# * (insert-at 'alfa '(a b c d) 2)
# (A ALFA B C D)

# a. Simple version
# 	@array	- your "@array" must always use "@" - even for a single element
#	.splice - Your array is also an object, you can call the method .splice
#		- offset - where to add (starting 0)
#		- length - how many to replace (0 for insert)
#		- What to add
my @array = <a b c d>;
@array.splice(1, 0, 'alfa');
say @array;

# b. Using a sub
# 	$in @arr, $pos - you can insert an array in the middle of your parameters
# 	The array is like a reference, so splice on the actual array, not a copy of	it
sub insert_at ($in, @arr, $pos) {
	@arr.splice($pos - 1, 0, $in);
}
my @array2 = <a b c d>;
insert_at('alfa', @array2, 2);
say @array2;<commit_msg>[99Problems] recode file to UTF-8, that's what Rakudo expects today<commit_after>use v6;

# NOTE: Experimenting with documentation for tutorials / help

# P21 (*) Insert an element at a given position into a list.
# 
# Example:
# * (insert-at 'alfa '(a b c d) 2)
# (A ALFA B C D)

# a. Simple version
# 	@array	- your "@array" must always use "@" - even for a single element
#	.splice - Your array is also an object, you can call the method .splice
#		- offset - where to add (starting 0)
#		- length - how many to replace (0 for insert)
#		- What to add
my @array = <a b c d>;
@array.splice(1, 0, 'alfa');
say @array;

# b. Using a sub
# 	$inâ @arr, $pos - you can insert an array in the middle of your parameters
# 	The array is like a reference, so splice on the actual array, not a copy of	it
sub insert_at ($in, @arr, $pos) {
	@arr.splice($pos - 1, 0, $in);
}
my @array2 = <a b c d>;
insert_at('alfa', @array2, 2);
say @array2;
{'fraction_non_alphanumeric': 0.13211719181868437, 'fraction_numerical': 0.017136539524599224, 'mean_word_length': 3.2789598108747047, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3186993', 'n_tokens_mistral': 690, 'n_tokens_neox': 661, 'n_words': 294}