안녕,
목록이나 행렬 목록에 새로운 Where 함수를 어떻게 사용할 수 있나요?
xs = {10, 20, 30, 50};
Where( Print(xs); xs ==10 );
xs = {[10 20], [30 50]};
Where( Print(xs); xs ==[10 20] );첫 번째에
xs = {10, 20, 30, 50};
v=Where( xs ==10 );
print(v);
두 번째는 잘 모르겠네요
첫 번째는 작업 예제로 사용되었습니다.:)
내부 인쇄 위치 :
xs가 실제로 루프 중에 각 개별 요소를 참조한다는 것을 보여줍니다.
[우와! - 쉬운 구문을 설명합니다.]
"각 개별 요소를 나타냅니다"
... 실제로 두 번째 예와 같습니다.
두 번째 결과가 궁금합니다. xs 는 [10 20] 이지만 Where 는 일치 항목을 찾지 못합니다.

목록에 항목을 하나 더 추가하면 어디가 깨질까요? 오류 메시지를 정말 이해할 수 없습니다
Not all sequences are the same size in access or evaluation of 'Where' , Bad Argument(
Print(xs);
xs == [10 20];
), Where/*###*/(Print(xs) ; xs == [10 20])
Names Default To Here(1);
xs = {[10 20], [30 50], [10 20]};
Where(
Print(xs);
xs == [10 20];
);
스크립팅 인덱스의 다른 예는 이에 가장 가까운 것으로 보이지만 이 경우 인덱스 1을 사용하는 것은 실제로 작동하지 않습니다.
@EvanMcCorkle
이렇게 간단하게 비교해보면
Names Default To Here(1);
xs = {[10 20], [30 50], [10 20]};
mask = Repeat(Eval List({[10 20]}), N Items(xs));
xs[1] == mask[1];
1을 돌려받지 못하고 [1 1]을 돌려받게 됩니다(따라서 각 경기마다 하나씩). All을 사용하여 이를 1로 변환할 수 있어야 하지만 Where도 이를 좋아하지 않습니다(행렬의 첫 번째 항목만 비교하는 것 같습니까?).
Names Default To Here(1);
xs = {[10 20], [30 20]};
Where(Show(xs == [10 20])); // [1 0] and [0 1]
xs[1]을 사용하면 세 번째 항목을 추가하거나 하나를 제거할 때까지 작동하므로 잘못된 항목을 비교하는 것일 가능성이 높습니다.
Names Default To Here(1);
xs = {[10 20], [30 20]};
r = Where(
Show(xs[1] == [10 20]);
xs[1] == [10 20];
);
마지막으로 많은 시행착오와 추측 작업을 거쳐 적어도 가끔씩은 효과가 있었습니다(마스크에 대해 큰 행렬을 만들고 싶은지 확실하지 않습니다). 이는 적절하게 문서화되지 않은 한 이러한 유형의 비교에 대해 Where()에서 기대할 수 있는 것이 아닙니다.
</CODE></PRE>
<P>또한 이 방법을 사용하면 Loc()을 사용하는 것보다 느린 것 같지만 내 테스트에 결함이 있을 수 있습니다.</P>
<DIV class="lia-spoiler-container"><A class="lia-spoiler-link" href="#" rel="nofollow noopener noreferrer" target="_blank">더보기...</A><NOSCRIPT>(읽을 하이라이트)</NOSCRIPT><DIV class="lia-spoiler-border"><DIV class="lia-spoiler-content">
<PRE><CODE class=" language-jsl">Names Default To Here(1);
testitems = 300;
//xs = {[10 20], [30 20], [10 20]};
xs = Repeat({[10 20]}, testitems / 3);
xs = xs || Repeat({[30 20]}, testitems / 3);
xs = xs || Repeat({[1 2]}, testitems / 3);
xs = xs[Random Shuffle(1::testitems)];
testcount = 10000;
where_speed = Repeat({.}, testcount);
loc_speed = Repeat({.}, testcount);
matches = Repeat({.}, testcount);
category = Repeat({""}, testcount);
expr1 = Expr(
wait(0);
a = HP Time();
mask = Repeat(Eval List({[10 20]}), N Items(xs));
r1 = Where(All(xs == mask));
wait(0);
b = HP Time();
);
expr2 = Expr(
wait(0);
c = HP Time();
r2 = Loc(xs, [10 20]);
wait(0);
d = HP Time();
);
For(i = 1, i <= testcount, i++,
wait(0);
If(Random Integer(1, 2) == 2,
expr2;
expr1;
cur_cat = "Loc";
,
expr1;
expr2;
cur_cat = "Where";
);
where_speed[i] = b - a;
loc_speed[i] = d - c;
category[i] = "Loc";
matches[i] = Try(All(r1 == r2), 0);
wait(0);
);
dt = New Table("Test",
Add Rows(testcount),
New Column("Row", Numeric, Ordinal, Formula(Row())),
New Column("Locs", Numeric, Continuous, Values(loc_speed)),
New Column("Where", Numeric, Continuous, Values(where_speed)),
New Column("Matches", Numeric, Nominal, Values(matches)),
New Column("Category", Character, Nominal, Values(category))
);
tab = dt << Tabulate(
Show Control Panel(0),
Add Table(
Column Table(Analysis Columns(:Locs, :Where)),
Row Table(
Grouping Columns(:Category),
Statistics(Mean, Median, Std Dev, Interquartile Range)
)
)
);Names Default To Here(1);
xs = {[10 20], [30 20], [10 20]};
mask = Repeat(Eval List({[10 20]}), N Items(xs));
r = Where(
//show(xs, mask, xs == mask, All(xs == mask));
All(xs == mask);
);
Mask를 통해 얻은 통찰력과 요령에 감사드립니다.
Where( xs[0,1] ==10 & xs[0,2] ==20 );
... 하지만 Loc을 이길 수 있는 기회는 없습니다.
좀 놀랍네요...

동일한 오류가 발생했습니다.
Not all sequences are the same size in access or evaluation of 'Where' , Bad Argument
이번에는 "Contains" 함수를 사용할 때입니다. "Get Rows Where" 함수 내에서 동일한 인수를 사용하면 예상대로 작동합니다.
최소한의 예는 다음과 같습니다.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
names = {"KATIE", "JAMES"};
r1 = dt << Get Rows Where( Contains(names, :name) );
r2 = Where( Contains(names, :name) );
Show( r1, r2 );
r1은 작동하지만 r2는 오류를 발생시킵니다.