<commit_before>/*
   WARNING: THIS WORKS AS EXPECTED ONLY IN THE CONTEXT OF NO MUTATION
   var x = 1;
   var xs = plSingleton(x); // xs = (1);
   x = 2; // xs = (2);
   If you are fine with this behavior, then go ahead, the gain in term of construction is pretty significant. (2op per element.) Otherwise, use the others constructors (lCons and ulCons) when constructing by hand, and then use the list manipulation functions from this file. They are compatible with each others, and from future usage, and the trend I am seeing at the moment, the other lists functions will probably disappear.
*/

/**
* plFoldL : (b -> a -> b) -> b -> List a -> b
*/
function plFoldL(@f){ return function(@b) { return function(@as) {
	var acc = @b, x, xs = @as;
	while (xs !== null) {
		xs(x, xs);
		acc = f(acc)(x);
	}
	return @acc;
};};}

/**
* plFoldLu : ((b, a) -> b) -> b -> List a -> b
*/
function plFoldLu(@f){ return function(@b) { return function(@as) {
	var acc = @b, x, xs = @as;
	while (xs !== null) {
		xs(x, xs);
		acc = f(acc, x);
	}
	return @acc;
};};}

/**
* plFoldR : (a -> b -> b) -> b -> List a -> b
*/
function plFoldR(@f) { return function(@b) { return function(@as) {
	return pulFoldR(f, b, as);
};};}

/**
* pulFoldR : ((a -> b -> b), b, List a) -> b
*/
function pulFoldR(@f, @b, @as) {
	if (as === null) { return @b; }
	else             {
		var x, xs;
		as(x, xs);
		return f(x)(pulFoldR(f, b, xs));
	}
}

/**
* pulFoldRu : (((a, b) -> b), b, List a) -> b
*/
function pulFoldRu(@f, @b, @as) {
	if (as === null) { return @b; }
	else             {
		var _x, _xs;
		as(_x, _xs);
		return f(_x, pulFoldRu(f, b, _xs));
	}
}

/**
* plMap : (a -> b) -> List a -> List b
*/
function plMap(@f) { return function (@xs) {
	return pulMap(f, xs);
};}

/**
* pulMap : ((a -> b), List a) -> List b
*/
function pulMap(@f, @xs) {
	if (xs === null) { return @xs; }
	else             {
		var _x, _xs;
		xs(_x, _xs);
		return pulCons(f(_x), pulMap(f, _xs));
	}
}

/**
* pulAppendMap : ((a -> b), List b, List a) -> List b
*/
function pulAppendMap(@f, @xs, @acc) {
	if (xs === null) { return @acc; }
	else             {
		var _x, _xs;
		xs(_x, _xs);
		return pulCons(f(_x), pulAppendMap(f, _xs, acc));
	}
}

/**
* plConcat : List (List a) -> List a
*/
function plConcat(@xss) {
	return pulFoldRu(pulAppend, null, xss);
}

/**
* plConcatMap : (a -> List b) -> List a -> List b
*/
function plConcatMap(@f) { return function(@xs) {
	return pulFoldRu(function(@x, @acc){return pulAppend(f(x), acc);}, null, xs);
};}

/**
* lApply : List (a -> b) -> List a -> List b
*/
function plApply(@fs) { return function(@xs) {
	return pulApply(fs, xs);
};}

/**
* pulApply : (List (a -> b), List a) -> List b
*/
function pulApply(@fs, @xs) {
	if (fs === null) { return null; }
	else             {
		var _f, _fs;
		fs(_f, _fs);
		return pulAppendMap(_f, xs, pulApply(_fs, xs));
	}
}

/**
* plAppend : List a -> List a -> List a
*/
function plAppend(@xs) { return function(@ys) {
		return pulAppend(xs, ys);
};}

/**
* pulAppend : (List a, List a) -> List a
*/
function pulAppend(@xs, @ys) {
	return pulFoldRu(pulCons, ys, xs);
}

/**
* plFilter : (a -> Bool) -> List a -> List a
*/
function plFilter(@p) { return function (@xs) {
	return pulFilter(p, xs);
};}

/**
* pulFilter : ((a -> Bool), List a) -> List a
*/
function pulFilter(@p, @xs){
	if (xs === null) { return @xs; }
	else             {
		var _x, _xs;
		xs(_x, _xs);
		if (p(_x)) { return pulCons(_x, pulFilter(p, _xs)); }
		else      { return pulFilter(p, _xs); }
	}
}

/**
* plIter : (a -> ()) -> List a -> ()
*/
function plIter(@f) { return function(@xs) {
	pulIter(f, xs);
};}

/**
* pulIter : ((a -> ()), List a) -> ()
*/
function pulIter(@f, @xs) {
	var _x, _xs = @xs;
	while (_xs !== null) {
		_xs(_x, _xs);
		f(_x);
	}
}
<commit_msg>corrected a type and added AppendFilter<commit_after>/*
   WARNING: THIS WORKS AS EXPECTED ONLY IN THE CONTEXT OF NO MUTATION
   var x = 1;
   var xs = plSingleton(x); // xs = (1);
   x = 2; // xs = (2);
   If you are fine with this behavior, then go ahead, the gain in term of construction is pretty significant. (2op per element.) Otherwise, use the others constructors (lCons and ulCons) when constructing by hand, and then use the list manipulation functions from this file. They are compatible with each others, and from future usage, and the trend I am seeing at the moment, the other lists functions will probably disappear.
*/

/**
* plFoldL : (b -> a -> b) -> b -> List a -> b
*/
function plFoldL(@f){ return function(@b) { return function(@as) {
	var acc = @b, x, xs = @as;
	while (xs !== null) {
		xs(x, xs);
		acc = f(acc)(x);
	}
	return @acc;
};};}

/**
* plFoldLu : ((b, a) -> b) -> b -> List a -> b
*/
function plFoldLu(@f){ return function(@b) { return function(@as) {
	var acc = @b, x, xs = @as;
	while (xs !== null) {
		xs(x, xs);
		acc = f(acc, x);
	}
	return @acc;
};};}

/**
* plFoldR : (a -> b -> b) -> b -> List a -> b
*/
function plFoldR(@f) { return function(@b) { return function(@as) {
	return pulFoldR(f, b, as);
};};}

/**
* pulFoldR : ((a -> b -> b), b, List a) -> b
*/
function pulFoldR(@f, @b, @as) {
	if (as === null) { return @b; }
	else             {
		var x, xs;
		as(x, xs);
		return f(x)(pulFoldR(f, b, xs));
	}
}

/**
* pulFoldRu : (((a, b) -> b), b, List a) -> b
*/
function pulFoldRu(@f, @b, @as) {
	if (as === null) { return @b; }
	else             {
		var _x, _xs;
		as(_x, _xs);
		return f(_x, pulFoldRu(f, b, _xs));
	}
}

/**
* plMap : (a -> b) -> List a -> List b
*/
function plMap(@f) { return function (@xs) {
	return pulMap(f, xs);
};}

/**
* pulMap : ((a -> b), List a) -> List b
*/
function pulMap(@f, @xs) {
	if (xs === null) { return @xs; }
	else             {
		var _x, _xs;
		xs(_x, _xs);
		return pulCons(f(_x), pulMap(f, _xs));
	}
}

/**
* pulAppendMap : ((a -> b), List a, List b) -> List b
*/
function pulAppendMap(@f, @xs, @acc) {
	if (xs === null) { return @acc; }
	else             {
		var _x, _xs;
		xs(_x, _xs);
		return pulCons(f(_x), pulAppendMap(f, _xs, acc));
	}
}

/**
* plConcat : List (List a) -> List a
*/
function plConcat(@xss) {
	return pulFoldRu(pulAppend, null, xss);
}

/**
* plConcatMap : (a -> List b) -> List a -> List b
*/
function plConcatMap(@f) { return function(@xs) {
	return pulFoldRu(function(@x, @acc){return pulAppend(f(x), acc);}, null, xs);
};}

/**
* pulConcatFilter : ((a -> Bool), List (List a)) -> List a
*/
function pulConcatFilter(@p, @xss) {}

/**
* lApply : List (a -> b) -> List a -> List b
*/
function plApply(@fs) { return function(@xs) {
	return pulApply(fs, xs);
};}

/**
* pulApply : (List (a -> b), List a) -> List b
*/
function pulApply(@fs, @xs) {
	if (fs === null) { return null; }
	else             {
		var _f, _fs;
		fs(_f, _fs);
		return pulAppendMap(_f, xs, pulApply(_fs, xs));
	}
}

/**
* plAppend : List a -> List a -> List a
*/
function plAppend(@xs) { return function(@ys) {
		return pulAppend(xs, ys);
};}

/**
* pulAppend : (List a, List a) -> List a
*/
function pulAppend(@xs, @ys) {
	return pulFoldRu(pulCons, ys, xs);
}

/**
* plFilter : (a -> Bool) -> List a -> List a
*/
function plFilter(@p) { return function (@xs) {
	return pulFilter(p, xs);
};}

/**
* pulFilter : ((a -> Bool), List a) -> List a
*/
function pulFilter(@p, @xs){
	if (xs === null) { return @xs; }
	else             {
		var _x, _xs;
		xs(_x, _xs);
		if (p(_x)) { return pulCons(_x, pulFilter(p, _xs)); }
		else       { return pulFilter(p, _xs); }
	}
}

/**
* plAppendFilter : (a -> Bool) -> List a -> List a -> List a
*/
function plAppendFilter(@p) { return function(@xs) {return function(@acc){
	return pulAppendFilter(p, xs, acc);
};};}

/**
* pulAppendFilter : ((a -> Bool), List a, List a) -> List a
*/
function pulAppendFilter(@p, @xs, @acc) {
	if (xs === null) { return @acc; }
	else             {
		var _x, _xs;
		xs(_x, _xs);
		if (p(_x)) { return pulCons(_x, pulAppendFilter(p, _xs, acc)); }
		else       { return pulAppendFilter(p, _xs, acc); }
	}
}

/**
* plIter : (a -> ()) -> List a -> ()
*/
function plIter(@f) { return function(@xs) {
	pulIter(f, xs);
};}

/**
* pulIter : ((a -> ()), List a) -> ()
*/
function pulIter(@f, @xs) {
	var _x, _xs = @xs;
	while (_xs !== null) {
		_xs(_x, _xs);
		f(_x);
	}
}

{'fraction_non_alphanumeric': 0.21304666503786954, 'fraction_numerical': 0.001221597849987784, 'mean_word_length': 2.836457357075914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 107, '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': '3654013', 'n_tokens_mistral': 3385, 'n_tokens_neox': 3265, 'n_words': 1011}