[#!: full-line executeEmbeds, phraseValueList = (("fout fout)("backtrack backtrack)) [#!: path_insertIn_fHand (link d_webWork 'fin Head_one.html') fout ; Howell QNial address [idx, slc] usage notes [#!: path_insertIn_fHand (link d_webWork 'fin Head_two.html') fout ; [#!: path_executeEmbedsInsertIn_fHand (link d_webWork 'Menu.html') phraseValueList ; [#!: path_executeEmbedsInsertIn_fHand (link d_webWork 'Menu projects.html') phraseValueList ; [#!: path_insertIn_fHand (link d_webWork 'normalStatus.html' ) fout ;

Howell QNial address [idx, slc] usage notes

Table of Contents



Introduction

This webPage illustrates the use of QNial addressing expressed as [idx = index, slc = slice] and conversions between them.
07Dec2022 note : a slice is a string expression used in a form : execute 'ary|slc' = slice of ary according to slc, where slc = '[ comma-separated [int, null] ]' in other words slc includes the enclosing square brackets?
Examples are pulled from my QNial tests. Typically optrs are executed using "ary_chk_..." style checking operators, which return errors that return fault conditions if appropriate. Typical are :
...ary_chk_slc_to_idxA_apply_optrPhr IS OP ary slc optrPhr - checks args with argOrder (ary slc)
...ary_chk_slc_to_idxA_testSimple := - tests for the conversion of idxA to slc

Results of ary_chk_slc_to_idxA_testSimple are shown as simple "line from a table" format, where each column indicates :
0 - OK?, 1 - tstName, 2 - ary, 3 - slc, 4 - resStdIdx, 5 - calcIdx

As the "sketch formating of normal QNial output does not indicate important distinctions in the "type" of result, and full use of the "diagram" mode is too detailed and obscures the results, I have added "diagram" results to the "sketch output in the examples below.

This ary is used for the examples below :
qnial> ary := (4 5 reshape (tell 30))
.0 .1 .2 .3 .4
.5 .6 .7 .8 .9
10 11 12 13 14
15 16 17 18 19

IGNORE the "." character (period) in the QNial [in, out]puts of this webPage. A HTML compacts spaces, and I don't want to use long html character codes, I use periods instead of spaces for formatting of a monospace font (all characters have the same width). This approach is [ugly, confusing], but very efficient (for me).

Note that BOTH the [slc -> idxA, iddxA -> slc] conversions REQUIRE (gage shape ary = aryShp) to convert properly. Rather than pass the shape to the conversion operators (optrs) as an argument, I elected to pass the entire ary, as that considerably simplifies downstream coding and reduces the number of [optr, test]s required!

01Jul2022 ary : cannot use addresses with [null, fault, atm, solitary, single] : qnial> a := [tell 10] +-------------------+ |0 1 2 3 4 5 6 7 8 9| +-------------------+ qnial> a@1 ?address qnial> a := single (tell 10)
o-------------------+
|0 1 2 3 4 5 6 7 8 9|
+-------------------+
qnial> a@1
?address



verBar - is an unlabeled QNial type = transpose (3 1 reshape '+|+')

problematic result to work with!!

-->[nextv] a := list null

-->[nextv] isLst a
l
-->[nextv] first a
?address
-->[nextv] diagram a
+
|
+
-->[nextv] b := single null
o+
||
++


idx MUST be a list of valence 1, shape = valence ary!!

Howell [slc, idx] optrs only apply to (1 <= (valence ary))
(or it won't generalize to higher dimension)
This applies to Howell's [idx, slc] optrs, not Qnial optrs
see ary_idx_to_slc - can convert to list in optrs?
as idx is already a list idxL is NOT used to designate, idxL means a List of idx

qnial> null 0 [null] [0] EACHLEFT choose a
++-+--------+-+
||0|?address|0|
++-+--------+-+


A slc MUST be a string, '[intLL comma-separated]'

(= 1 (valence slc)), gage shape indxLL = valence ary!!
as slc is already a list slcL is NOT used to designate, slcL means a List of slc

yields [isSingle idx], eg '[4]' -> [[4]] :
+--+-------------+-----------------+------------++-------------+------------+
| l|str01_slcInt |the bigg fat cow |[4] = '[4]' ||+-+..........|+-+.........|
+--+-------------+-----------------+------------+||4| = [[4]] .||4| = [[4]] |
.................................................|+-+..........|+-+.........|
.................................................+-------------+------------+
+--+-------------+----------------------------------------------------+
| l|str01_slcInt |note [[4]], should be OK, no space before isAtm slc |
+--+-------------+----------------------------------------------------+



A slc composed of a simple intL, eg '[int1, int2, ...]'

yields [isLt idx] -> eg [[ 2, 3]] :
+--+-------------+---------------+------------+--------------+--------------+
| l|intA05_intL .| 0 .1 .2 .3 .4 |[ 2, 3].....|+---+.........|+---+.........|
| .|.............| 5 .6 .7 .8 .9 |............||2 3| = [2 3] ||2 3| = [2 3] |
| .|.............|10 11 12 13 14 |............|+---+.........|+---+.........|
| .|.............|15 16 17 18 19 |............+--------------+--------------+
+--+-------------+---------------+------------+
+--+-------------+---------------+
| l|intA05_intL .|should work OK |
+--+-------------+---------------+

Example :
qnial> a := ary_slc_to_idxA ary '[ 2, 3]'
+---+
|2 3|
+---+

The operator that converts a "max one idx per axis" slc to idxA, converts any "single" results ((0 null) = [valence, gage shape] ary) to a simple list with one element, as a single is not a legitimate idx (index of addresses) for subsequent use.

...ary_slc_to_idxA..IS OP..ary..slc..
{..LOCAL......idx..;..
...idx..:=..cart EACH execute..(`,..itm_cut_ary..(front rest..slc))..;..
...IF..(isSingle..idx)..THEN..idx..:=..[first idx]..;..ENDIF..;..
...idx..
}..

To reconfirm that the results is a simple list of an idx :
qnial> diagram a
+-----+
|+-+-+|
||2|3||
|+-+-+|
+-----+



A slc composed of an intLL, eg '[int01 int02, int11 int12, ...]'

yields an idxA, eg '[ 2 3, 1 2]' :
+--+-------------+---------------+------------++-------------+-------------+
| l|intA03_slcL..| 0..1..2..3..4 |[ 2 3, 1 2] ||+---+---+....|+---+---+....|
|..|............ | 5..6..7..8..9 |............|||2 1|2 2|....||2 1|2 2|....|
|..|............ |10 11 12 13 14 |............||+---+---+....|+---+---+....|
|..|............ |15 16 17 18 19 |............|||3 1|3 2|....||3 1|3 2|....|
+--+-------------+---------------+------------+|+---+---+....|+---+---+....|
.............................................. +-------------+-------------+
+--+-------------+-------------+
| l|intA03_slcL..|should be OK |
+--+-------------+-------------+

Example :
qnial> a := ary_slc_to_idxA ary '[ 2 3, 1 2]'
+---+---+
|2 1|2 2|
+---+---+
|3 1|3 2|
+---+---+
qnial> diagram a
+-----+-----+
|+-+-+|+-+-+|
||2|1|||2|2||
|+-+-+|+-+-+|
+-----+-----+
|+-+-+|+-+-+|
||3|1|||3|2||
|+-+-+|+-+-+|
+-----+-----+



Comparisons of [atoms, solitaries, singles

# 25Jun2022 tests using :
ary = first single ary
qnial> a := cart 5 6
o---+
|5 6|
+---+
qnial> first a
5 6
isSingle a
qnial> isSingle a
l

# 26Jun2022
AND (= 0 (valence a)) (= null (gage shape a))
qnial> [valence, gage shape] a
+-++
|0||
+-++
>> but does this apply to [null]? - nyet
qnial> [valence, gage shape] [null]
1 1
qnial> [valence, gage shape] [5]
1 1
>> O, this may be better as a test?
qnial> isSingle a
l

# 03Jul2022 tests
qnial> EACH isSingle `g 4 "phrase l 2.71828
lllll
qnial> EACH isAtm `g 4 "phrase l 2.71828
lllll
>> NUTS!!! Are Atm = Single?
My defs :
isSingle IS OP ary { (0 null) = [valence, gage shape] ary }
isAtm IS OP ary { OR [isboolean, isinteger, isreal, ischar, isphrase, isfault] ary }
My defn of isSingle is FAR more efficient than isAtm!!!
[isAtm, isSingle] null
qnial> [isAtm, isSingle] null
oo

# 03Jul2022 nyet - single can hold an entire ary!!
a := single (2 3 4 5 6 reshape (tell 1000))
qnial> a := single (2 3 4 5 6 reshape (tell 1000))
o-----------------------------------------------------------------------------------------------------------
| 0..1..2..3..4..5........ 30 31 32 33 34 35........ 60 61 62 63 64 65..........90..91..92..93..94..95.. 360
| 6..7..8..9 10 11........ 36 37 38 39 40 41........ 66 67 68 69 70 71..........96..97..98..99 100 101.. 366
|12 13 14 15 16 17........ 42 43 44 45 46 47........ 72 73 74 75 76 77........ 102 103 104 105 106 107.. 372
|18 19 20 21 22 23........ 48 49 50 51 52 53........ 78 79 80 81 82 83........ 108 109 110 111 112 113.. 378
|24 25 26 27 28 29........ 54 55 56 57 58 59........ 84 85 86 87 88 89........ 114 115 116 117 118 119.. 384
|..........................................................................................................
|120 121 122 123 124 125.. 150 151 152 153 154 155.. 180 181 182 183 184 185.. 210 211 212 213 214 215.. 480
|126 127 128 129 130 131.. 156 157 158 159 160 161.. 186 187 188 189 190 191.. 216 217 218 219 220 221.. 486
|132 133 134 135 136 137.. 162 163 164 165 166 167.. 192 193 194 195 196 197.. 222 223 224 225 226 227.. 492
|138 139 140 141 142 143.. 168 169 170 171 172 173.. 198 199 200 201 202 203.. 228 229 230 231 232 233.. 498
|144 145 146 147 148 149.. 174 175 176 177 178 179.. 204 205 206 207 208 209.. 234 235 236 237 238 239.. 504
|..........................................................................................................
|240 241 242 243 244 245.. 270 271 272 273 274 275.. 300 301 302 303 304 305.. 330 331 332 333 334 335.. 600
|246 247 248 249 250 251.. 276 277 278 279 280 281.. 306 307 308 309 310 311.. 336 337 338 339 340 341.. 606
|252 253 254 255 256 257.. 282 283 284 285 286 287.. 312 313 314 315 316 317.. 342 343 344 345 346 347.. 612
|258 259 260 261 262 263.. 288 289 290 291 292 293.. 318 319 320 321 322 323.. 348 349 350 351 352 353.. 618
|264 265 266 267 268 269.. 294 295 296 297 298 299.. 324 325 326 327 328 329.. 354 355 356 357 358 359.. 624
+-----------------------------------------------------------------------------------------------------------
~::~
--------------------------------------------------------------------------------------------------+
361 362 363 364 365.. 390 391 392 393 394 395.. 420 421 422 423 424 425.. 450 451 452 453 454 455|
367 368 369 370 371.. 396 397 398 399 400 401.. 426 427 428 429 430 431.. 456 457 458 459 460 461|
373 374 375 376 377.. 402 403 404 405 406 407.. 432 433 434 435 436 437.. 462 463 464 465 466 467|
379 380 381 382 383.. 408 409 410 411 412 413.. 438 439 440 441 442 443.. 468 469 470 471 472 473|
385 386 387 388 389.. 414 415 416 417 418 419.. 444 445 446 447 448 449.. 474 475 476 477 478 479|
..................................................................................................|
481 482 483 484 485.. 510 511 512 513 514 515.. 540 541 542 543 544 545.. 570 571 572 573 574 575|
487 488 489 490 491.. 516 517 518 519 520 521.. 546 547 548 549 550 551.. 576 577 578 579 580 581|
493 494 495 496 497.. 522 523 524 525 526 527.. 552 553 554 555 556 557.. 582 583 584 585 586 587|
499 500 501 502 503.. 528 529 530 531 532 533.. 558 559 560 561 562 563.. 588 589 590 591 592 593|
505 506 507 508 509.. 534 535 536 537 538 539.. 564 565 566 567 568 569.. 594 595 596 597 598 599|
..................................................................................................|
601 602 603 604 605.. 630 631 632 633 634 635.. 660 661 662 663 664 665.. 690 691 692 693 694 695|
607 608 609 610 611.. 636 637 638 639 640 641.. 666 667 668 669 670 671.. 696 697 698 699 700 701|
613 614 615 616 617.. 642 643 644 645 646 647.. 672 673 674 675 676 677.. 702 703 704 705 706 707|
619 620 621 622 623.. 648 649 650 651 652 653.. 678 679 680 681 682 683.. 708 709 710 711 712 713|
625 626 627 628 629.. 654 655 656 657 658 659.. 684 685 686 687 688 689.. 714 715 716 717 718 719|
--------------------------------------------------------------------------------------------------+
qnial> [isAtm, isSingle] a
ol
>> Ah hah! correct in rethinking, so first test isAtm, then test isSolitary.

qnial> b := first a
... details not show (simply the "contents of a")
qnial> gage shape b
2 3 4 5 6
qnial> b@(0 0 1 1 1)
37
qnial> b@[0 0 1 1 1]
?address
qnial> b@(0 0 1 [1] 1)
?address
>> so idx can't [be, have] a solitary





28Jun2022 initial work, ?date? initial posting
[#!: full-line executeEmbeds, phraseValueList = (("fout fout)("backtrack backtrack)) [#!: path_executeEmbedsInsertIn_fHand (link d_webWork 'fin Footer.html') phraseValueList ;