// Generated by bynkc — do not edit by hand.
// commons catalogue

import { Ok, Err, Some, None, type Result, type Option, type ValidationError } from "./runtime.js";

export function bigDoubled(xs: readonly number[]): readonly number[] {
  return ((xs).filter((__x: number) => ((x) => x > 2)(__x))).map((__x: number) => ((x) => x * 2)(__x));
}

export function fanOut(xs: readonly number[]): readonly number[] {
  return (xs).flatMap((__x: number) => ((x) => [x, x])(__x));
}

export function window(xs: readonly number[]): readonly number[] {
  return ((xs).slice(Math.max(0, 1))).slice(0, Math.max(0, 2));
}

export function howMany(xs: readonly number[]): number {
  return ((xs).filter((__x: number) => ((x) => x > 0)(__x))).length;
}

export function anyPositive(xs: readonly number[]): boolean {
  return (xs).some((__x: number) => ((x) => x > 0)(__x));
}

export function allPositive(xs: readonly number[]): boolean {
  return (xs).every((__x: number) => ((x) => x > 0)(__x));
}

export function head(xs: readonly number[]): Option<number> {
  return ((__xs: readonly number[]) => __xs.length > 0 ? Some(__xs[0]) : None)(xs);
}

export function headOrZero(xs: readonly number[]): number {
  return ((__xs: readonly number[], __d: number) => __xs.length > 0 ? __xs[0] : __d)(xs, 0);
}

export function demo(): number {
  const xs = [1, 2, 3, 4];
  return howMany(bigDoubled(xs)) + headOrZero(window(fanOut(xs)));
}

