Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,7 @@
comb{(=0)=: (0,1+(-1) -1)1+ -1}
4 comb 5
0 1 2 3
0 1 2 5
0 1 4 5
0 3 4 5
2 3 4 5

View file

@ -0,0 +1,7 @@
comb{
{
0=:
0=:
((),¨(-1)r),r1
}
}

View file

@ -0,0 +1,17 @@
01.10 S M=3
01.20 S N=5
01.30 D 2
01.40 Q
02.10 F I=1,M;S C(I)=I-1
02.20 D 3
02.30 S I=M
02.40 S C(I)=C(I)+1
02.50 I (C(I)-N+M-I)2.8
02.60 S I=I-1
02.70 I (-I)2.4;R
02.80 F J=I+1,M;S C(J)=C(J-1)+1
02.90 G 2.2
03.10 F I=1,M;T %3,C(I)
03.20 T !

View file

@ -1,3 +1 @@
combr=: dyad define M.
if. (x>:y)+.0=x do. i.(x<:y),x else. (0,.x combr&.<: y),1+x combr y-1 end.
)
combr=: ((0,.$:&.<:),1+($:<:))` (<:i.@,[) @.(>:+.0=[)M.

View file

@ -1 +1,3 @@
combr=: ((0,.$:&.<:),1+($:<:))` ([:i.<:,[) @.(>:+.0=[)M.
combr=: dyad define M.
if. (x>:y)+.0=x do. i.(x<:y),x else. (0,.x combr&.<: y),1+x combr y-1 end.
)

View file

@ -1,7 +1 @@
combr1=: dyad define
if.(x=#y) +. x=1 do.
y
else.
(({.y) ,. (x-1) combr (}.y)) , (x combr }.y)
end.
)
combr1=: (({.@],.<:@[$:}.@]),($:}.))` ] @.((= #)+.1=[)

View file

@ -1 +1,7 @@
combr1=: (({.@],.<:@($:}.)),($:}.))` ] @.((= #)+.1=[)
combr1=: dyad define
if.(x=#y) +. x=1 do.
y
else.
(({.y) ,. (x-1) combr (}.y)) , (x combr }.y)
end.
)

View file

@ -0,0 +1,29 @@
import java.util.ArrayList;
import java.util.List;
public final class Combinations {
public static void main(String[] args) {
System.out.println(createCombinations(List.of( 0, 1, 2, 3, 4 ), 3));
System.out.println(createCombinations(List.of( "Crosby", "Nash", "Stills", "Young" ), 3));
}
private static <T> List<List<T>> createCombinations(List<T> elements, int k) {
List<List<T>> combinations = new ArrayList<List<T>>();
createCombinations(elements, k, new ArrayList<T>(), combinations, 0);
return combinations;
}
private static <T> void createCombinations(
List<T> elements, int k, List<T> accumulator, List<List<T>> combinations, int index) {
if ( accumulator.size() == k ) {
combinations.addFirst( new ArrayList<T>(accumulator) );
} else if ( k - accumulator.size() <= elements.size() - index ) {
createCombinations(elements, k, accumulator, combinations, index + 1);
accumulator.add(elements.get(index));
createCombinations(elements, k, accumulator, combinations, index + 1);
accumulator.removeLast();
}
}
}

View file

@ -0,0 +1,8 @@
main :: [sys_message]
main = [Stdout (lay (map show (comb 3 5)))]
comb :: num->num->[[num]]
comb m n = comb' m [0..n-1]
where comb' 0 xs = [[]]
comb' m [] = []
comb' m (x:xs) = map (x:) (comb' (m-1) xs) ++ comb' m xs

View file

@ -0,0 +1,2 @@
##
(0..4).combinations(3).printlines;

View file

@ -0,0 +1,23 @@
$ENTRY Go {
= <Prout <Comb 3 5>>;
};
Comb {
s.M s.N = <Comb1 s.M <Iota 0 <- s.N 1>>>;
};
Comb1 {
0 e.X = ();
s.M = ;
s.M s.X e.X = <PfxEach s.X <Comb1 <- s.M 1> e.X>> <Comb1 s.M e.X>;
};
PfxEach {
s.X = ;
s.X (e.X) e.Y = (s.X e.X) <PfxEach s.X e.Y>;
};
Iota {
s.E s.E = s.E;
s.S s.E = s.S <Iota <+ 1 s.S> s.E>;
};

View file

@ -0,0 +1,7 @@
operator (m comb n)
[by 0..~$n] -> #
when <[](..~$m)> do [$..., by $(last)~..~$n] -> #
otherwise $!
end comb
(3 comb 5) -> !OUT::write