September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,17 @@
' Array concatenation
OPTION BASE 1
CONST asize = 2
CONST bsize = 3
DECLARE a[asize] TYPE NUMBER
DECLARE b[bsize] TYPE NUMBER
' BaCon has no array concatenation builtin, it will need to be done by hand
LOCAL c TYPE NUMBER ARRAY asize + bsize
FOR i = 1 TO asize
c[i] = a[i]
NEXT
FOR i = 1 TO bsize
c[asize + i] = b[i]
NEXT

View file

@ -0,0 +1,19 @@
DIM a(3), b(4)
a() = 1, 2, 3, 4
b() = 5, 6, 7, 8, 9
PROCconcat(a(), b(), c())
FOR i% = 0 TO DIM(c(),1)
PRINT c(i%)
NEXT
END
DEF PROCconcat(a(), b(), RETURN c())
LOCAL s%, na%, nb%
s% = ^a(1) - ^a(0) : REM Size of each array element
na% = DIM(a(),1)+1 : REM Number of elements in a()
nb% = DIM(b(),1)+1 : REM Number of elements in b()
DIM c(na%+nb%-1)
SYS "RtlMoveMemory", ^c(0), ^a(0), s%*na%
SYS "RtlMoveMemory", ^c(na%), ^b(0), s%*nb%
ENDPROC

View file

@ -0,0 +1,17 @@
10 X=4 : Y=5
20 DIM A(X) : DIM B(Y) : DIM C(X+Y)
30 FOR I=1 TO X
40 : A(I) = I
50 NEXT
60 FOR I=1 TO Y
70 : B(I) = I*10
80 NEXT
90 FOR I=1 TO X
100 : C(I) = A(I)
110 NEXT
120 FOR I=1 TO Y
130 : C(X+I) = B(I)
140 NEXT
150 FOR I=1 TO X+Y
160 : PRINT C(I);
170 NEXT