Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,24 +0,0 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Cantor_Set is
|
||||
|
||||
subtype Level_Range is Integer range 1 .. 5;
|
||||
Image : array (Level_Range) of String (1 .. 81) := (others => (others => ' '));
|
||||
|
||||
procedure Cantor (Level : Natural; Length : Natural; Start : Natural) is
|
||||
begin
|
||||
if Level in Level_Range then
|
||||
Image (Level) (Start .. Start + Length - 1) := (others => '*');
|
||||
Cantor (Level + 1, Length / 3, Start);
|
||||
Cantor (Level + 1, Length / 3, Start + 2 * Length / 3);
|
||||
end if;
|
||||
end Cantor;
|
||||
begin
|
||||
Cantor (Level => Level_Range'First,
|
||||
Length => 81,
|
||||
Start => 1);
|
||||
|
||||
for L in Level_Range loop
|
||||
Ada.Text_IO.Put_Line (Image (L));
|
||||
end loop;
|
||||
end Cantor_Set;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
width: 81
|
||||
height: 5
|
||||
|
||||
lines: array.of: height repeat `*` width
|
||||
lines: array.of: height repeat '*' width
|
||||
|
||||
cantor: function [start length idx].export:[lines][
|
||||
seg: length / 3
|
||||
|
|
@ -9,7 +9,7 @@ cantor: function [start length idx].export:[lines][
|
|||
|
||||
loop idx..dec height 'i [
|
||||
loop (start + seg).. dec start + 2 * seg 'j
|
||||
-> set lines\[i] j ` `
|
||||
-> set lines\[i] j ' '
|
||||
]
|
||||
cantor start seg idx+1
|
||||
cantor start + 2 * seg seg idx+1
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define WIDTH 81
|
||||
#define HEIGHT 5
|
||||
|
||||
char lines[HEIGHT][WIDTH];
|
||||
|
||||
void init() {
|
||||
int i, j;
|
||||
for (i = 0; i < HEIGHT; ++i) {
|
||||
for (j = 0; j < WIDTH; ++j) lines[i][j] = '*';
|
||||
}
|
||||
}
|
||||
|
||||
void cantor(int start, int len, int index) {
|
||||
int i, j, seg = len / 3;
|
||||
if (seg == 0) return;
|
||||
for (i = index; i < HEIGHT; ++i) {
|
||||
for (j = start + seg; j < start + seg * 2; ++j) lines[i][j] = ' ';
|
||||
}
|
||||
cantor(start, seg, index + 1);
|
||||
cantor(start + seg * 2, seg, index + 1);
|
||||
}
|
||||
|
||||
void print() {
|
||||
int i, j;
|
||||
for (i = 0; i < HEIGHT; ++i) {
|
||||
for (j = 0; j < WIDTH; ++j) printf("%c", lines[i][j]);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
init();
|
||||
cantor(0, WIDTH, 1);
|
||||
print();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. CANTOR.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 SETTINGS.
|
||||
03 NUM-LINES PIC 9 VALUE 5.
|
||||
03 FILL-CHAR PIC X VALUE '#'.
|
||||
01 VARIABLES.
|
||||
03 CUR-LINE.
|
||||
05 CHAR PIC X OCCURS 81 TIMES.
|
||||
03 WIDTH PIC 99.
|
||||
03 CUR-SIZE PIC 99.
|
||||
03 POS PIC 99.
|
||||
03 MAXPOS PIC 99.
|
||||
03 NEXTPOS PIC 99.
|
||||
03 I PIC 99.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
BEGIN.
|
||||
COMPUTE WIDTH = 3 ** (NUM-LINES - 1).
|
||||
PERFORM INIT.
|
||||
MOVE WIDTH TO CUR-SIZE.
|
||||
DISPLAY CUR-LINE.
|
||||
PERFORM DO-LINE UNTIL CUR-SIZE IS EQUAL TO 1.
|
||||
STOP RUN.
|
||||
|
||||
INIT.
|
||||
PERFORM INIT-CHAR VARYING I FROM 1 BY 1
|
||||
UNTIL I IS GREATER THAN WIDTH.
|
||||
|
||||
INIT-CHAR.
|
||||
MOVE FILL-CHAR TO CHAR(I).
|
||||
|
||||
DO-LINE.
|
||||
DIVIDE 3 INTO CUR-SIZE.
|
||||
MOVE 1 TO POS.
|
||||
SUBTRACT CUR-SIZE FROM WIDTH GIVING MAXPOS.
|
||||
PERFORM BLANK-REGIONS UNTIL POS IS GREATER THAN MAXPOS.
|
||||
DISPLAY CUR-LINE.
|
||||
|
||||
BLANK-REGIONS.
|
||||
ADD CUR-SIZE TO POS.
|
||||
PERFORM BLANK-CHAR CUR-SIZE TIMES.
|
||||
|
||||
BLANK-CHAR.
|
||||
MOVE SPACE TO CHAR(POS).
|
||||
ADD 1 TO POS.
|
||||
|
|
@ -1,18 +1,15 @@
|
|||
(phixonline)-->
|
||||
<span style="color: #004080;">integer</span> <span style="color: #000000;">n</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">5</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #000000;">w</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">power</span><span style="color: #0000FF;">(</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">n</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">),</span>
|
||||
<span style="color: #000000;">len</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">w</span>
|
||||
<span style="color: #004080;">string</span> <span style="color: #000000;">line</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'#'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">w</span><span style="color: #0000FF;">)&</span><span style="color: #008000;">"\n"</span>
|
||||
|
||||
<span style="color: #008080;">while</span> <span style="color: #000000;">1</span> <span style="color: #008080;">do</span>
|
||||
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">line</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">len</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">then</span> <span style="color: #008080;">exit</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #000000;">len</span> <span style="color: #0000FF;">/=</span> <span style="color: #000000;">3</span>
|
||||
<span style="color: #004080;">integer</span> <span style="color: #000000;">pos</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span>
|
||||
<span style="color: #008080;">while</span> <span style="color: #000000;">pos</span><span style="color: #0000FF;"><(</span><span style="color: #000000;">w</span><span style="color: #0000FF;">-</span><span style="color: #000000;">len</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
|
||||
<span style="color: #000000;">pos</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">len</span>
|
||||
<span style="color: #000000;">line</span><span style="color: #0000FF;">[</span><span style="color: #000000;">pos</span><span style="color: #0000FF;">..</span><span style="color: #000000;">pos</span><span style="color: #0000FF;">+</span><span style="color: #000000;">len</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">' '</span>
|
||||
<span style="color: #000000;">pos</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">len</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
|
||||
<!--
|
||||
integer n = 5,
|
||||
w = power(3,n-1),
|
||||
len = w
|
||||
string line = repeat('#',w)&"\n"
|
||||
do
|
||||
puts(1,line)
|
||||
len /= 3
|
||||
integer pos = 1
|
||||
do
|
||||
pos += len
|
||||
line[pos..pos+len-1] = ' '
|
||||
pos += len
|
||||
until pos>(w-len)
|
||||
until len=1
|
||||
puts(1,line)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
from __future__ import print_function, division
|
||||
|
||||
WIDTH = 81
|
||||
HEIGHT = 5
|
||||
|
||||
lines=[]
|
||||
lines = []
|
||||
|
||||
def cantor(start, len, index):
|
||||
seg = len / 3
|
||||
seg = len // 3 # from division
|
||||
if seg == 0:
|
||||
return None
|
||||
for it in xrange(HEIGHT-index):
|
||||
for it in range(HEIGHT - index):
|
||||
i = index + it
|
||||
for jt in xrange(seg):
|
||||
for jt in range(seg):
|
||||
j = start + seg + jt
|
||||
pos = i * WIDTH + j
|
||||
lines[pos] = ' '
|
||||
|
|
@ -16,9 +19,9 @@ def cantor(start, len, index):
|
|||
cantor(start + seg * 2, seg, index + 1)
|
||||
return None
|
||||
|
||||
lines = ['*'] * (WIDTH*HEIGHT)
|
||||
lines = ['*'] * (WIDTH * HEIGHT)
|
||||
cantor(0, WIDTH, 1)
|
||||
|
||||
for i in xrange(HEIGHT):
|
||||
for i in range(HEIGHT):
|
||||
beg = WIDTH * i
|
||||
print ''.join(lines[beg : beg+WIDTH])
|
||||
print(''.join(lines[beg : beg + WIDTH])) # from print_function
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
cantorSet <- function() {
|
||||
depth <- 6L
|
||||
cs <- vector('list', depth)
|
||||
cs <- vector("list", depth)
|
||||
cs[[1L]] <- c(0, 1)
|
||||
for(k in seq_len(depth)) {
|
||||
cs[[k + 1L]] <- unlist(sapply(seq_len(length(cs[[k]]) / 2L), function(j) {
|
||||
|
|
@ -35,15 +35,15 @@ cantorSetGraph <- function() {
|
|||
)
|
||||
|
||||
require(ggplot2)
|
||||
g <- ggplot(df, aes_string(x = 'x_start', y = 'depth')) +
|
||||
geom_segment(aes_string(xend = 'x_end', yend = 'depth', size = 3)) +
|
||||
g <- ggplot(df, aes(x = x_start, y = depth)) +
|
||||
geom_segment(aes(xend = x_end, yend = depth, linewidth = 3)) +
|
||||
scale_y_continuous(trans = "reverse") +
|
||||
theme(
|
||||
axis.title = element_blank(),
|
||||
axis.line = element_blank(),
|
||||
axis.text = element_blank(),
|
||||
axis.ticks = element_blank(),
|
||||
legend.position = 'none',
|
||||
legend.position = "none",
|
||||
aspect.ratio = 1/5
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue