|
> No.1717[元記事へ]
続き
EXTERNAL FUNCTION STIRLING(N)
LET STIRLING=SQR(N*2*PI)*N^N*EXP(-N) !'FACT(N)
END FUNCTION
EXTERNAL FUNCTION AREA3(X1,Y1,X2,Y2,X3,Y3)
LET AREA3=ABS(X1*Y2+X2*Y3+X3*Y1-Y1*X2-Y2*X3-Y3*X1)/2 !'三角形の面積
END FUNCTION
EXTERNAL FUNCTION AREA(N, X(), Y()) !'n角形の面積
LET A = X(N - 1) * Y(1) - X(1) * Y(N - 1)
FOR I = 2 TO N - 1
LET A = A + X(I - 1) * Y(I) - X(I) * Y(I - 1)
NEXT I
LET AREA = ABS(A) / 2
END FUNCTION
EXTERNAL FUNCTION NINT(X,N)
LET NINT=INT(10^N*X+.5)/10^N
END FUNCTION
EXTERNAL FUNCTION ISLOWER(X$)
IF ORD(X$)>=97 AND ORD(X$)<=122 THEN LET ISLOWER=-1 ELSE LET ISLOWER=0 !'小文字なら真
END FUNCTION
EXTERNAL FUNCTION ISUPPER(X$)
IF ORD(X$)>=65 AND ORD(X$)<=90 THEN LET ISUPPER=-1 ELSE LET ISUPPER=0 !'大文字なら真
END FUNCTION
EXTERNAL FUNCTION ISDIGIT(X$)
IF ORD(X$)>=48 AND ORD(X$)<=57 THEN LET ISDIGIT=-1 ELSE LET ISDIGIT=0 !'数字なら真
END FUNCTION
EXTERNAL FUNCTION ISALNUM(X$)
IF ISLOWER(X$)=-1 OR ISUPPER(X$)=-1 OR ISDIGIT(X$)=-1 THEN LET ISALNUM=-1 ELSE LET ISALNUM=0
END FUNCTION
EXTERNAL FUNCTION ISALPHA(X$)
IF ISLOWER(X$)=-1 OR ISUPPER(X$)=-1 THEN LET ISALPHA=-1 ELSE LET ISALPHA=0
END FUNCTION
EXTERNAL FUNCTION ISGRAPH(X$)
IF ORD(X$)>=33 AND ORD(X$)<=126 THEN LET ISGRAPH=-1 ELSE LET ISGRAPH=0 !'印字可能文字なら真(空白除く)
END FUNCTION
EXTERNAL FUNCTION ISCNTRL(X$)
IF ORD(X$)<=31 OR ORD(X$)=127 THEN LET ISCNTRL=-1 ELSE LET ISCNTRL=0 !'制御文字なら真
END FUNCTION
EXTERNAL FUNCTION ISPRINT(X$)
IF ORD(X$)>=32 AND ORD(X$)<=126 THEN LET ISPRINT=-1 ELSE LET ISPRINT=0 !'印字可能文字なら真
END FUNCTION
EXTERNAL FUNCTION ISSPACE(X$)
IF ORD(X$)>=9 AND ORD(X$)<=13 OR ORD(X$)=32 THEN LET ISSPACE=-1 ELSE LET ISSPACE=0 !'空白、タブ、復帰、改項、垂直タブ、改頁なら真
END FUNCTION
EXTERNAL FUNCTION ISHEXDIGIT(X$)
IF ISDIGIT(X$)=-1 OR ORD(X$)>=65 AND ORD(X$)<=70 OR ORD(X$)>=97 AND ORD(X$)<=102 THEN LET ISHEXDIGIT=-1 ELSE LET ISHEXDIGIT=0 !'16進表示文字なら真
END FUNCTION
EXTERNAL FUNCTION ISPUNCT(X$)
IF ORD(X$)>=33 AND ORD(X$)<=47 OR ORD(X$)>=58 AND ORD(X$)<=64 OR ORD(X$)>=91 AND ORD(X$)<=96 OR ORD(X$)>=123 AND ORD(X$)<=126 THEN LET ISPUNCT=-1 ELSE LET ISPUNCT=0 !'区切り文字なら真
END FUNCTION
EXTERNAL FUNCTION ISKANJI(X$)
IF LEN(X$)<>BLEN(X$) THEN LET ISKANJI=-1 ELSE LET ISKANJI=0 !'2バイト文字なら真
END FUNCTION
EXTERNAL FUNCTION FIB(N)
LET FIB=INT((((1+SQR(5))/2)^N)/SQR(5)+.5) !'フィボナッチ数列
END FUNCTION
EXTERNAL FUNCTION FIB2(N)
LET A =1
LET B =1
FOR I=1 TO N-2
LET A=A+B
LET B=A-B
NEXT I
LET FIB2=A
END FUNCTION
EXTERNAL FUNCTION MOVEX(X,N,S) !'テンキーによるキャラクター移動(X方向)
IF S=1 OR S=4 OR S=7 THEN LET MOVEX=X+N
IF S=3 OR S=6 OR S=9 THEN LET MOVEX=X-N
END FUNCTION
EXTERNAL FUNCTION MOVEY(Y,N,S) !'テンキーによるキャラクター移動(Y方向)
IF S=7 OR S=8 OR S=9 THEN LET MOVEY=Y-N
IF S=1 OR S=2 OR S=3 THEN LET MOVEY=Y+N
END FUNCTION
EXTERNAL FUNCTION MOVEX2(X,N,S)
LET MOVEX2=X+N*(MOD((S-1),3)-1)
END FUNCTION
EXTERNAL FUNCTION MOVEY2(Y,N,S)
LET MOVEY2=Y+N*(INT((1-S)/3)+1)
END FUNCTION
EXTERNAL FUNCTION LAGRANGE2(X0,X1,Y0,Y1,T)
LET LAGRANGE2=Y0*(T-X1)/(X0-X1)+Y1*(T-X0)/(X1-X0) !'ラグランジュ補間
END FUNCTION
EXTERNAL FUNCTION LAGRANGE3(X0,X1,X2,Y0,Y1,Y2,T)
LET LAGRANGE3=((X2-T)*LAGRANGE2(X0,X1,Y0,Y1,T)-(X1-T)*LAGRANGE2(X0,X2,Y0,Y2,T))/(X2-X1)
END FUNCTION
EXTERNAL FUNCTION LAGRANGE4(X0,X1,X2,X3,Y0,Y1,Y2,Y3,T)
LET LAGRANGE4=((X3-T)*LAGRANGE3(X0,X1,X2,Y0,Y1,Y2,T)-(X2-T)*LAGRANGE3(X0,X1,X3,Y0,Y1,Y3,T))/(X3-X2)
END FUNCTION
EXTERNAL FUNCTION LAGRANGE5(X0,X1,X2,X3,X4,Y0,Y1,Y2,Y3,Y4,T)
LET LAGRANGE5=((X4-T)*LAGRANGE4(X0,X1,X2,X3,Y0,Y1,Y2,Y3,T)-(X3-T)*LAGRANGE4(X0,X1,X2,X4,Y0,Y1,Y2,Y4,T))/(X4-X3)
END FUNCTION
EXTERNAL FUNCTION LAGRANGE(N, X(), Y(), T)
FOR I = 1 TO N
LET P = Y(I)
FOR J = 1 TO N
IF I <> J THEN LET P = P * (T - X(J)) / (X(I) - X(J)) !'ラグランジュ補間
NEXT J
LET S = S + P
NEXT I
LET LARGRANGE = S
END FUNCTION
EXTERNAL FUNCTION Y3(X,X0,Y0,X1,Y1,X2,Y2)
LET Y3=((X-X1)*(X-X2))/((X0-X1)*(X0-X2))*Y0+((X-X0)*(X-X2))/((X1-X0)*(X1-X2))*Y1+((X-X0)*(X-X1))/((X2-X0)*(X2-X1))*Y2 !'3点を通る2次方程式
END FUNCTION
EXTERNAL FUNCTION EQV(X,Y)
LET EQV=BITNOT(BITXOR(X,Y)) !'X EQV Y
END FUNCTION
EXTERNAL FUNCTION AND2(X,Y)
LET AND2=BITNOT(BITOR(BITNOT(X),BITNOT(Y))) !'X AND Y
END FUNCTION
EXTERNAL FUNCTION OR2(X,Y)
LET OR2=BITNOT(BITAND(BITNOT(X),BITNOT(Y))) !'X OR Y
END FUNCTION
EXTERNAL FUNCTION NAND(X,Y)
LET NAND=BITNOT(BITAND(X,Y)) !'X NAND Y
END FUNCTION
EXTERNAL FUNCTION NAND2(X,Y)
LET NAND2=BITOR(BITNOT(X),BITNOT(Y))
END FUNCTION
EXTERNAL FUNCTION NOR(X,Y)
LET NOR=BITNOT(BITOR(X,Y)) !'X NOR Y
END FUNCTION
EXTERNAL FUNCTION NOR2(X,Y)
LET NOR2=BITAND(BITNOT(X),BITNOT(Y))
END FUNCTION
EXTERNAL FUNCTION XOR2(X,Y)
LET XOR2=BITNOT(BITOR(BITAND(X,Y),NOR(X,Y))) !'X XOR Y
END FUNCTION
EXTERNAL FUNCTION XOR3(X,Y)
LET XOR3=BITOR(BITAND(BITNOT(X),Y),BITAND(X,BITNOT(Y)))
END FUNCTION
EXTERNAL FUNCTION XOR4(X,Y)
LET XOR4=BITAND(BITOR(X,Y),BITOR(BITNOT(X),BITNOT(Y)))
END FUNCTION
EXTERNAL FUNCTION XOR5(X,Y)
LET XOR5=NAND(NAND(X,BITNOT(Y)),NAND(BITNOT(X),Y))
END FUNCTION
EXTERNAL FUNCTION IMP(X,Y)
LET IMP=BITOR(BITNOT(X),Y) !'X IMP Y
END FUNCTION
EXTERNAL FUNCTION IMP2(X,Y)
LET IMP2=BITNOT(BITAND(BITNOT(Y),X))
END FUNCTION
EXTERNAL FUNCTION NIMP(X,Y)
LET NIMP=BITNOT(BITOR(BITNOT(X),Y)) !'X NIMP Y
END FUNCTION
EXTERNAL FUNCTION NIMP2(X,Y)
LET NIMP2=BITAND(BITNOT(Y),X)
END FUNCTION
EXTERNAL FUNCTION NIMP3(X,Y)
LET NIMP3=BITNOT(IMP(X,Y))
END FUNCTION
EXTERNAL FUNCTION GCD(M,N) !'最大公約数
DO WHILE N <> 0
LET T = MOD(M , N)
LET M = N
LET N = T
LOOP
LET GCD=M
END FUNCTION
EXTERNAL FUNCTION LCM(A, B)
LET LCM=A*B/GCD(A,B) !'最小公倍数
END FUNCTION
EXTERNAL FUNCTION LCM3(A, B, C)
LET LCM3=A*B*C/GCD(A,B)/GCD(B,C)/GCD(A,C)*GCD(A,GCD(B,C))
END FUNCTION
EXTERNAL FUNCTION WHICH(N,X,Y)
IF N<>0 THEN LET WHICH=X ELSE LET WHICH=Y
END FUNCTION
EXTERNAL FUNCTION COSINE(OX, OY, PX, PY, MX, MY)
LET COSINE=((PX - OX) * (MX - OX) + (PY - OY) * (MY - OY)) / SQR((PX - OX) * (PX - OX) + (PY - OY) * (PY - OY)) / SQR((MX - OX) * (MX - OX) + (MY - OY) * (MY - OY))
END FUNCTION
EXTERNAL FUNCTION COSINE3D(AX,AY,AZ,BX,BY,BZ)
LET COSINE3D=(AX*BX+AY*BY+AZ*BZ)/SQR(AX^2+AY^2+AZ^2)/SQR(BX^2+BY^2+BZ^2)
END FUNCTION
EXTERNAL FUNCTION NSTR$(Y,N) !'N進文字列
LET X=Y
LET B$=""
DO
LET A$=MID$("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",MOD(X,N)+1,1)
LET B$=A$&B$
LET X=INT(X/N)
LOOP UNTIL X=0
LET NSTR$=B$
END FUNCTION
EXTERNAL FUNCTION ANGLE2(X,Y)
LET ANGLE2=ASIN(Y/SQR(X*X+Y*Y))
END FUNCTION
|
|