Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,6 @@
matrix a=J(20,20,0)
forv i=1/20 {
forv j=1/20 {
matrix a[`i',`j']=runiformint(1,20)
}
}

View file

@ -0,0 +1,16 @@
local q 0
forv i=1/20 {
forv j=1/20 {
display "check `i',`j'"
if el("a",`i',`j')==20 {
display "found at `i',`j'"
local q 1
continue, break
}
}
if `q' continue, break
}
if !`q' {
display "not found"
}

View file

@ -0,0 +1,17 @@
local q 0
local i=1
while !`q' & `i'<=20 {
local j=1
while !`q' & `j'<=20 {
display "check `i',`j'"
if el("a",`i',`j')==20 {
display "found at `i',`j'"
local q 1
}
local ++j
}
local ++i
}
if !`q' {
display "not found"
}

View file

@ -0,0 +1,18 @@
capture {
forv i=1/20 {
forv j=1/20 {
display "check `i',`j'"
if el("a",`i',`j')==20 {
display "found at `i',`j'"
exit -1
}
}
}
}
if _rc==-1 {
// value was found
}
else if _rc==0 {
display "not found"
}
else exit _rc

View file

@ -0,0 +1,52 @@
function findval1(a,x,i0,j0) {
n=rows(a)
p=cols(a)
for (i=1; i<=n; i++) {
for (j=1; j<=p; j++) {
if (a[i,j]==x) {
i0=i
j0=j
return(1)
}
}
}
return(0)
}
function findval2(a,x,i0,j0) {
n=rows(a)
p=cols(a)
q=0
for (i=1; i<=n; i++) {
for (j=1; j<=p; j++) {
if (a[i,j]==x) {
i0=i
j0=j
q=1
goto END
}
}
}
END:
return(q)
}
function findval3(a,x,i0,j0) {
n=rows(a)
p=cols(a)
q=0
for (i=1; i<=n; i++) {
for (j=1; j<=p; j++) {
if (a[i,j]==x) {
i0=i
j0=j
q=1
break
}
}
if (q) {
break
}
}
return(q)
}

View file

@ -0,0 +1,4 @@
a=st_matrix("a")
findval1(a,20,i=.,j=.)
findval2(a,20,i=.,j=.)
findval3(a,20,i=.,j=.)