Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -12,7 +12,7 @@
|
|||
(defn smerge3 [xs ys zs]
|
||||
(smerge xs (smerge ys zs)))
|
||||
|
||||
(defn map*n [n ks] (map #(* n %) ks))
|
||||
(defn map*n [n ks] (map #(*' n %) ks))
|
||||
|
||||
(def hamming
|
||||
(lazy-seq
|
||||
|
|
|
|||
31
Task/Hamming-numbers/PL-I/hamming-numbers.pli
Normal file
31
Task/Hamming-numbers/PL-I/hamming-numbers.pli
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
(subscriptrange):
|
||||
Hamming: procedure options (main); /* 14 November 2013 */
|
||||
declare (H(3000), t) fixed (15);
|
||||
declare (i, j, k, m, n) fixed binary;
|
||||
declare swaps bit (1);
|
||||
|
||||
on underflow ;
|
||||
|
||||
m = 0; n = 12;
|
||||
do k = 0 to n;
|
||||
do j = 0 to n;
|
||||
do i = 0 to n;
|
||||
m = m + 1;
|
||||
H(m) = 2**i * 3**j * 5**k;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
/* sort */
|
||||
swaps = '1'b;
|
||||
do while (swaps); /* Cocktail-shaker sort is adequate, because values are largely sorted */
|
||||
swaps = '0'b;
|
||||
do i = 1 to m-1, i-1 to 1 by -1;
|
||||
if H(i) > H(i+1) then /* swap */
|
||||
do; t = H(i); H(i) = H(i+1); H(i+1) = t; swaps = '1'b; end;
|
||||
end;
|
||||
end;
|
||||
do i = 1 to m;
|
||||
put skip data (H(i));
|
||||
end;
|
||||
put skip data (H(1653));
|
||||
end Hamming;
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
numeric digits 100 /*ensure we have enough precision*/
|
||||
call hamming 1, 20 /*show the first ──► twentieth #s*/
|
||||
call hamming 1691 /*show the 1,691st Hamming number*/
|
||||
call hamming 1000000 /*show the one millionth number*/
|
||||
call hamming 10000000 /*show the 10th millionth number*/
|
||||
call hamming 1000000 /*show the one millionth number.*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────HAMMING subroutine──────────────────*/
|
||||
hamming: procedure; parse arg x,y; if y=='' then y=x; w=length(y)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
numeric digits 100 /*ensure we have enough precision*/
|
||||
call hamming 1, 20 /*show the first ──► twentieth #s*/
|
||||
call hamming 1691 /*show the 1,691st Hamming number*/
|
||||
call hamming 1000000 /*show the one millionth number*/
|
||||
call hamming 1000000 /*show the one millionth number.*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────HAMMING subroutine──────────────────*/
|
||||
hamming: procedure; parse arg x,y; if y=='' then y=x; w=length(y)
|
||||
|
|
@ -16,9 +16,9 @@ hamming: procedure; parse arg x,y; if y=='' then y=x; w=length(y)
|
|||
if _3 < m then m =_3 /*is this less than the minimum? */
|
||||
if _5 < m then m =_5 /* " " " " " " */
|
||||
@.n = m /*now, assign the next Hamming #.*/
|
||||
if _2 == m then #2 =#2 + 1 /*# already defined? Use next #.*/
|
||||
if _3 == m then #3 =#3 + 1 /*" " " " " " */
|
||||
if _5 == m then #5 =#5 + 1 /*" " " " " " */
|
||||
if _2 == m then #2 = #2 + 1 /*# already defined? Use next #.*/
|
||||
if _3 == m then #3 = #3 + 1 /*" " " " " " */
|
||||
if _5 == m then #5 = #5 + 1 /*" " " " " " */
|
||||
end /*n*/
|
||||
do j=x to y /*W is used to align the index. */
|
||||
say 'Hamming('right(j,w)") =" @.j /*list 'em, Dano.*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue