Changeset 28231 in project for wiki/eggref/4/tuples
 Timestamp:
 02/01/13 14:30:25 (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/4/tuples
r27163 r28231 4 4 == tuples 5 5 6 Tuples are a datatype which has much in common with vectors. Namely they store a finite number of items with random access and make them available via (tupleref tup n). But contrary to vectors, the items can only by accessed but not assigned to. If you want to change a particular item, you must package it into a box or a single, which is a special tuple storing exactly one item, which can be changed via singleset! without changing the identity of the single object itself. 7 8 singles are the only tuples, which can assign to their content. Other special tuples are empty, couple and triple. Note, that couples can be used instead of pairs to implement immutable lists. 6 Tuples are a datatype which has much in common with vectors. Namely they 7 store a finite number of items with random access and make them 8 available via (tupleref tup n). But contrary to vectors, the items can 9 only by accessed but not assigned to. If you want to change a particular 10 item, you must package it into a box or a single, which is a special 11 tuple storing exactly one item, which can be changed via singleset! 12 without changing the identity of the single object itself. 13 14 singles are the only tuples, which can assign to their content. Other 15 special tuples are couple and triple. They are all packaged in their 16 own modules, and all of them use another module, rawtuples, which 17 contains the basic implementations without any checks. 18 19 Note, that couples can be used instead of pairs to 20 implement immutable lists. 9 21 10 22 == Documentation 11 23 12 In this implementation skiplists are implemented in the Design by 13 Contract style, i.e. using the contracts module. A corollary of this is, 14 that the documentation is included in one of the two modules in form of 15 a procedure with the module's name. Apart from this documentation 16 procedure the two modules, %tuples and tuples, have the same 17 interface. The first module contains the raw implementations of the 18 procedures, the second imports the first with prefix % and wraps those 19 prefixed routines with contracts. 20 21 ==== tuples 22 23 <procedure>(tuples [sym])</procedure> 24 25 returns all available routines of the module when called without an 26 argument, but when called with one of these routines as a symbol, 27 returns its contract and documentation string. 28 29 Another way to get the complete documentation is to use printdoclist from the contracts module. Issuing 30 31 <enscript highlight=scheme> 32 (import tuples (only contracts printdoclist)) 33 (withoutputtofile "tuples.docu" (lambda () (printdoclist))) 34 </enscript> 35 36 you'll get a file tuples.docu which is the basis for the following 37 documentation. 24 In this implementation tuples and their relatives (except rawtuples) 25 are implemented in the Design by Contract style, i.e. using the dbc egg. 26 A corollary of this is, that the documentation is included in each of 27 these modules in form of a procedure with the module's name. Called 28 without any argument, the list of exported symbols is shown, with such a 29 symbol as argument, the symbol's documentation is shown, and with a string 30 argument, some wikilike documentation is printed to a file, which you 31 can inspect below. 32 33 === module tuples 34 35 ==== list>tuple 36 37 <procedure>(list>tuple lst)</procedure> 38 39 function (result) 40 41 <enscript highlight=scheme> 42 43 (list>tuple lst) 44 (list? lst) 45 (and (%tuple? result) (= (length lst) (%tuplelength result))) 46 47 </enscript> 48 49 ==== tuple 50 51 <procedure>(tuple . args)</procedure> 52 53 function (result) 54 55 <enscript highlight=scheme> 56 57 (tuple . args) 58 #t 59 (%tuple? result) 60 61 </enscript> 62 63 ==== tuple>list 64 65 <procedure>(tuple>list tup)</procedure> 66 67 function (result) 68 69 <enscript highlight=scheme> 70 71 (tuple>list tup) 72 (%tuple? tup) 73 (list? result) 74 75 </enscript> 76 77 ==== tuple>vector 78 79 <procedure>(tuple>vector tup)</procedure> 80 81 function (result) 82 83 <enscript highlight=scheme> 84 85 (tuple>vector tup) 86 (%tuple? tup) 87 (vector? result) 88 89 </enscript> 90 91 ==== tupleappend 92 93 <procedure>(tupleappend . tups)</procedure> 94 95 function (result) 96 97 <enscript highlight=scheme> 98 99 (tupleappend . tups) 100 ((listof? %tuple?) tups) 101 (and (%tuple? result) (= (tuplelength result) (apply + (map tuplelength tups)))) 102 103 </enscript> 104 105 ==== tuplebutleft 106 107 <procedure>(tuplebutleft tup)</procedure> 108 109 function (result) 110 111 <enscript highlight=scheme> 112 113 (tuplebutleft tup) 114 (and (%tuple? tup) (positive? (%tuplelength tup))) 115 (and (%tuple result) (= (%tuplelength result) ( (%tuplelength tup) 1))) 116 117 </enscript> 118 119 ==== tuplebutright 120 121 <procedure>(tuplebutright tup)</procedure> 122 123 function (result) 124 125 <enscript highlight=scheme> 126 127 (tuplebutright tup) 128 (and (%tuple? tup) (positive? (%tuplelength tup))) 129 (and (%tuple result) (= (%tuplelength result) ( (%tuplelength tup) 1))) 130 131 </enscript> 132 133 ==== tupleconsleft 134 135 <procedure>(tupleconsleft arg tup)</procedure> 136 137 function (result) 138 139 <enscript highlight=scheme> 140 141 (tupleconsleft arg tup) 142 (%tuple? tup) 143 (and (%tuple result) (= (%tuplelength result) (+ (%tuplelength tup) 1))) 144 145 </enscript> 146 147 ==== tupleconsright 148 149 <procedure>(tupleconsright arg tup)</procedure> 150 151 function (result) 152 153 <enscript highlight=scheme> 154 155 (tupleconsright arg tup) 156 (%tuple? tup) 157 (and (%tuple result) (= (%tuplelength result) (+ (%tuplelength tup) 1))) 158 159 </enscript> 160 161 ==== tuplecopy 162 163 <procedure>(tuplecopy tup)</procedure> 164 165 function (result) 166 167 <enscript highlight=scheme> 168 169 (tuplecopy tup) 170 (%tuple tup) 171 (%tuple result) 172 173 </enscript> 174 175 ==== tupleempty? 176 177 <procedure>(tupleempty? xpr)</procedure> 178 179 function (result) 180 181 <enscript highlight=scheme> 182 183 (tupleempty? xpr) 184 #t 185 (boolean? result) 186 187 </enscript> 188 189 ==== tupleeq? 190 191 <procedure>(tupleeq? tup0 tup1)</procedure> 192 193 function (result) 194 195 <enscript highlight=scheme> 196 197 (tupleeq? tup0 tup1) 198 (and (%tuple? tup0) (%tuple? tup1)) 199 (boolean? result) 200 201 </enscript> 202 203 ==== tupleeql? 204 205 <procedure>(tupleeql? eql? tup0 tup1)</procedure> 206 207 function (result) 208 209 <enscript highlight=scheme> 210 211 (tupleeql? eql? tup0 tup1) 212 (and (procedure? eql?) (%tuple? tup0) (%tuple? tup1)) 213 (boolean? result) 214 215 </enscript> 216 217 ==== tupleequal? 218 219 <procedure>(tupleequal? tup0 tup1)</procedure> 220 221 function (result) 222 223 <enscript highlight=scheme> 224 225 (tupleequal? tup0 tup1) 226 (and (%tuple? tup0) (%tuple? tup1)) 227 (boolean? result) 228 229 </enscript> 230 231 ==== tupleeqv? 232 233 <procedure>(tupleeqv? tup0 tup1)</procedure> 234 235 function (result) 236 237 <enscript highlight=scheme> 238 239 (tupleeqv? tup0 tup1) 240 (and (%tuple? tup0) (%tuple? tup1)) 241 (boolean? result) 242 243 </enscript> 244 245 ==== tuplefind 246 247 <procedure>(tuplefind ok? tup)</procedure> 248 249 function (result) 250 251 <enscript highlight=scheme> 252 253 (tuplefind ok? tup) 254 (and (procedure? ok?) (%tuple? tup)) 255 (or (not result) (and (cardinal? result) (< result (%tuplelength tup)) "index of found item")) 256 257 </enscript> 258 259 ==== tupleforeach 260 261 <procedure>(tupleforeach proc tup . tups)</procedure> 262 263 command ((old new (lambda (proc tup . tups) #t))) 264 265 <enscript highlight=scheme> 266 267 (tupleforeach proc tup . tups) 268 (and (procedure? proc) (%tuple tup) ((listof? %tuple?) tups) (apply = (%tuplelength tup) (map %tuplelength tups))) 269 "proc applied to each item" 270 271 </enscript> 272 273 ==== tuplefromupto 274 275 <procedure>(tuplefromupto tup . interval)</procedure> 276 277 function (result) 278 279 <enscript highlight=scheme> 280 281 (tuplefromupto tup . interval) 282 (and (%tuple tup) ((listof? (lambda (x) (and (cardinal? x) (<= x (%tuplelength tup))))) interval) (<= (length interval) 2) (apply <= 0 interval)) 283 (and (%tuple? result) (= (%tuplelength result) (case (length interval) ((0) (%tuplelength tup)) ((1) ( (%tuplelength tup) (car interval))) ((2) ( (cadr interval) (car interval)))))) 284 285 </enscript> 286 287 ==== tuplehead 288 289 <procedure>(tuplehead tup n)</procedure> 290 291 function (result) 292 293 <enscript highlight=scheme> 294 295 (tuplehead tup n) 296 (and (%tuple? tup) (<= n (%tuplelength tup))) 297 (and (%tuple result) (= (%tuplelength result) n)) 298 299 </enscript> 300 301 ==== tupleleft 302 303 <procedure>(tupleleft tup)</procedure> 304 305 function (result) 306 307 <enscript highlight=scheme> 308 309 (tupleleft tup) 310 (and (%tuple? tup) (positive? (%tuplelength tup))) 311 "tup's leftmost item" 312 313 </enscript> 314 315 ==== tuplelength 316 317 <procedure>(tuplelength tup)</procedure> 318 319 function (result) 320 321 <enscript highlight=scheme> 322 323 (tuplelength tup) 324 (%tuple? tup) 325 (cardinal? result) 326 327 </enscript> 328 329 ==== tuplemap 330 331 <procedure>(tuplemap fn tup . tups)</procedure> 332 333 function (result) 334 335 <enscript highlight=scheme> 336 337 (tuplemap fn tup . tups) 338 (and (procedure? fn) (%tuple? tup) ((listof? %tuple?) tups) (apply = (%tuplelength tup) (map %tuplelength tups))) 339 (and (%tuple? result) (= (%tuplelength tup) (%tuplelength result))) 340 341 </enscript> 342 343 ==== tupleof? 344 345 <procedure>(tupleof? ok?)</procedure> 346 347 function (result) 348 349 <enscript highlight=scheme> 350 351 (tupleof? ok?) 352 (procedure? ok?) 353 (procedure? result) 354 355 </enscript> 356 357 ==== tupleref 358 359 <procedure>(tupleref tup n)</procedure> 360 361 function (result) 362 363 <enscript highlight=scheme> 364 365 (tupleref tup n) 366 (and (%tuple? tup) (cardinal? n) (< 1 n (%tuplelength tup))) 367 "tup's nth item" 368 369 </enscript> 370 371 ==== tuplereverse 372 373 <procedure>(tuplereverse tup)</procedure> 374 375 function (result) 376 377 <enscript highlight=scheme> 378 379 (tuplereverse tup) 380 (%tuple? tup) 381 (and (%tuple result) (= (%tuplelength result) (%tuplelength tup))) 382 383 </enscript> 384 385 ==== tupleright 386 387 <procedure>(tupleright tup)</procedure> 388 389 function (result) 390 391 <enscript highlight=scheme> 392 393 (tupleright tup) 394 (and (%tuple? tup) (positive? (%tuplelength tup))) 395 "tup's rightmost item" 396 397 </enscript> 398 399 ==== tupletail 400 401 <procedure>(tupletail tup n)</procedure> 402 403 function (result) 404 405 <enscript highlight=scheme> 406 407 (tupletail tup n) 408 (and (%tuple? tup) (<= n (%tuplelength tup))) 409 (and (%tuple result) (= (%tuplelength result) ( (%tuplelength tup) n))) 410 411 </enscript> 412 413 ==== tuple? 414 415 <procedure>(tuple? xpr)</procedure> 416 417 function (result) 418 419 <enscript highlight=scheme> 420 421 (tuple? xpr) 422 #t 423 (boolean? result) 424 425 </enscript> 426 427 ==== vector>tuple 428 429 <procedure>(vector>tuple vec)</procedure> 430 431 function (result) 432 433 <enscript highlight=scheme> 434 435 (vector>tuple vec) 436 (vector? vec) 437 (and (%tuple? result) (= (%tuplelength result) (vectorlength vec))) 438 439 </enscript> 440 441 === Module triples 442 443 ==== triple 444 445 <procedure>(triple x y z)</procedure> 446 447 function (result) 448 449 <enscript highlight=scheme> 450 451 (triple x y z) 452 #t 453 (%triple? result) 454 455 </enscript> 456 457 ==== triple>tuple 458 459 <procedure>(triple>tuple trp)</procedure> 460 461 function (result) 462 463 <enscript highlight=scheme> 464 465 (triple>tuple trp) 466 (%triple? trp) 467 (and (%tuple? result) (= (%tuplelength result) 3)) 468 469 </enscript> 470 471 ==== tripleeq? 472 473 <procedure>(tripleeq? trp0 trp1)</procedure> 474 475 function (result) 476 477 <enscript highlight=scheme> 478 479 (tripleeq? trp0 trp1) 480 (and (%triple? trp0) (%triple? trp1)) 481 (boolean? result) 482 483 </enscript> 484 485 ==== tripleeql? 486 487 <procedure>(tripleeql? eql? trp0 trp1)</procedure> 488 489 function (result) 490 491 <enscript highlight=scheme> 492 493 (tripleeql? eql? trp0 trp1) 494 (and (procedure? eql?) (%triple? trp0) (%triple? trp1)) 495 (boolean? result) 496 497 </enscript> 498 499 ==== tripleequal? 500 501 <procedure>(tripleequal? trp0 trp1)</procedure> 502 503 function (result) 504 505 <enscript highlight=scheme> 506 507 (tripleequal? trp0 trp1) 508 (and (%triple? trp0) (%triple? trp1)) 509 (boolean? result) 510 511 </enscript> 512 513 ==== tripleeqv? 514 515 <procedure>(tripleeqv? trp0 trp1)</procedure> 516 517 function (result) 518 519 <enscript highlight=scheme> 520 521 (tripleeqv? trp0 trp1) 522 (and (%triple? trp0) (%triple? trp1)) 523 (boolean? result) 524 525 </enscript> 526 527 ==== tripleleft 528 529 <procedure>(tripleleft trp)</procedure> 530 531 function (result) 532 533 <enscript highlight=scheme> 534 535 (tripleleft trp) 536 (%triple? trp) 537 "leftmost item" 538 539 </enscript> 540 541 ==== triplemiddle 542 543 <procedure>(triplemiddle trp)</procedure> 544 545 function (result) 546 547 <enscript highlight=scheme> 548 549 (triplemiddle trp) 550 (%triple? trp) 551 "item in the middle" 552 553 </enscript> 38 554 39 555 ==== tripleright 40 556 41 <procedure>(tripleright tup)</procedure> 42 43 returns the right item of a triple 44 45 ==== triplemiddle 46 47 <procedure>(triplemiddle tup)</procedure> 48 49 returns the middle item of a triple 50 51 ==== tripleleft 52 53 <procedure>(tripleleft tup)</procedure> 54 55 returns the left item of a triple 56 57 ==== triple 58 59 <procedure>(triple x y z)</procedure> 60 61 constructor for a tuple storing two items 557 <procedure>(tripleright trp)</procedure> 558 559 function (result) 560 561 <enscript highlight=scheme> 562 563 (tripleright trp) 564 (%triple? trp) 565 "rightmost item" 566 567 </enscript> 62 568 63 569 ==== triple? … … 65 571 <procedure>(triple? x)</procedure> 66 572 67 tests for a tuple storing two items 573 function (result) 574 575 <enscript highlight=scheme> 576 577 (triple? x) 578 #t 579 (boolean? result) 580 581 </enscript> 582 583 === Module couples 584 585 ==== couple 586 587 <procedure>(couple x y)</procedure> 588 589 function (result) 590 591 <enscript highlight=scheme> 592 593 (couple x y) 594 #t 595 (%couple? result) 596 597 </enscript> 598 599 ==== couple>tuple 600 601 <procedure>(couple>tuple cpl)</procedure> 602 603 function (result) 604 605 <enscript highlight=scheme> 606 607 (couple>tuple cpl) 608 (%couple? cpl) 609 (and (%tuple? result) (= (%tuplelength result) 2)) 610 611 </enscript> 612 613 ==== coupleeq? 614 615 <procedure>(coupleeq? cpl0 cpl1)</procedure> 616 617 function (result) 618 619 <enscript highlight=scheme> 620 621 (coupleeq? cpl0 cpl1) 622 (and (%couple? cpl0) (%couple? cpl1)) 623 (boolean? result) 624 625 </enscript> 626 627 ==== coupleeql? 628 629 <procedure>(coupleeql? eql? cpl0 cpl1)</procedure> 630 631 function (result) 632 633 <enscript highlight=scheme> 634 635 (coupleeql? eql? cpl0 cpl1) 636 (and (procedure? eql?) (%couple? cpl0) (%couple? cpl1)) 637 (boolean? result) 638 639 </enscript> 640 641 ==== coupleequal? 642 643 <procedure>(coupleequal? cpl0 cpl1)</procedure> 644 645 function (result) 646 647 <enscript highlight=scheme> 648 649 (coupleequal? cpl0 cpl1) 650 (and (%couple? cpl0) (%couple? cpl1)) 651 (boolean? result) 652 653 </enscript> 654 655 ==== coupleeqv? 656 657 <procedure>(coupleeqv? cpl0 cpl1)</procedure> 658 659 function (result) 660 661 <enscript highlight=scheme> 662 663 (coupleeqv? cpl0 cpl1) 664 (and (%couple? cpl0) (%couple? cpl1)) 665 (boolean? result) 666 667 </enscript> 668 669 ==== coupleleft 670 671 <procedure>(coupleleft cpl)</procedure> 672 673 function (result) 674 675 <enscript highlight=scheme> 676 677 (coupleleft cpl) 678 (%couple? cpl) 679 "leftmost item" 680 681 </enscript> 68 682 69 683 ==== coupleright 70 684 71 <procedure>(coupleright tup)</procedure> 72 73 returns the right item of a couple 74 75 ==== coupleleft 76 77 <procedure>(coupleleft tup)</procedure> 78 79 returns the left item of a couple 80 81 ==== couple 82 83 <procedure>(couple x y)</procedure> 84 85 constructor for a tuple storing two items 685 <procedure>(coupleright cpl)</procedure> 686 687 function (result) 688 689 <enscript highlight=scheme> 690 691 (coupleright cpl) 692 (%couple? cpl) 693 "rightmost item" 694 695 </enscript> 86 696 87 697 ==== couple? … … 89 699 <procedure>(couple? x)</procedure> 90 700 91 tests for a tuple storing two items 701 function (result) 702 703 <enscript highlight=scheme> 704 705 (couple? x) 706 #t 707 (boolean? result) 708 709 </enscript> 710 711 === Module singles 712 713 ==== single 714 715 <procedure>(single x)</procedure> 716 717 function (result) 718 719 <enscript highlight=scheme> 720 721 (single x) 722 #t 723 (%single? result) 724 725 </enscript> 726 727 ==== singleeq? 728 729 <procedure>(singleeq? sgl0 sgl1)</procedure> 730 731 function (result) 732 733 <enscript highlight=scheme> 734 735 (singleeq? sgl0 sgl1) 736 (and (%single? sgl0) (%single? sgl1)) 737 (boolean? result) 738 739 </enscript> 740 741 ==== singleeql? 742 743 <procedure>(singleeql? eql? sgl0 sgl1)</procedure> 744 745 function (result) 746 747 <enscript highlight=scheme> 748 749 (singleeql? eql? sgl0 sgl1) 750 (and (procedure? eql?) (%single? sgl0) (%single? sgl1)) 751 (boolean? result) 752 753 </enscript> 754 755 ==== singleequal? 756 757 <procedure>(singleequal? sgl0 sgl1)</procedure> 758 759 function (result) 760 761 <enscript highlight=scheme> 762 763 (singleequal? sgl0 sgl1) 764 (and (%single? sgl0) (%single? sgl1)) 765 (boolean? result) 766 767 </enscript> 768 769 ==== singleeqv? 770 771 <procedure>(singleeqv? sgl0 sgl1)</procedure> 772 773 function (result) 774 775 <enscript highlight=scheme> 776 777 (singleeqv? sgl0 sgl1) 778 (and (%single? sgl0) (%single? sgl1)) 779 (boolean? result) 780 781 </enscript> 782 783 ==== singleref 784 785 <procedure>(singleref sg)</procedure> 786 787 function (result) 788 789 <enscript highlight=scheme> 790 791 (singleref sg) 792 (%single? sg) 793 "sg's stored item" 794 795 </enscript> 92 796 93 797 ==== singleset! 94 798 95 <procedure>(singleset! sg arg)</procedure> 96 97 <enscript highlight=scheme> 98 (domain (%single? sg) (true? arg)) 99 (effect (state (%tuplestate sg) arg)) 100 </enscript> 101 102 replaces state of sg with arg 103 104 ==== singleref 105 106 <procedure>(singleref sg)</procedure> 107 108 <enscript highlight=scheme> 109 (domain (%single? sg)) 110 </enscript> 111 112 returns the state of the single object sg 113 114 ==== single 115 116 <procedure>(single xpr)</procedure> 117 118 <enscript highlight=scheme> 119 (domain (true? xpr)) 120 (range (%single? result)) 121 </enscript> 122 123 package xpr into a box so that it can be modified 799 <procedure>(singleset! sg x)</procedure> 800 801 command ((old new (lambda (sg x) (%singleref sg)))) 802 803 <enscript highlight=scheme> 804 805 (singleset! sg x) 806 (%single? sg) 807 (equal? new x) 808 809 </enscript> 124 810 125 811 ==== single? 126 812 127 <procedure>(single? xpr)</procedure> 128 129 check, if xpr evaluates to a single 130 131 ==== empty 132 133 <procedure>(empty)</procedure> 134 135 constructor for an empty tuple 136 137 ==== empty? 138 139 <procedure>(empty? x)</procedure> 140 141 tests for an empty tuple 142 143 ==== tupleforeach 144 145 <procedure>(tupleforeach proc tup)</procedure> 146 147 <enscript highlight=scheme> 148 (domain (%tuple? tup) (procedure? proc) a one parameter procedure) 149 </enscript> 150 151 apply a one parameter procedure to each item of tup 152 153 ==== tuple>list 154 155 <procedure>(tuple>list tup)</procedure> 156 157 <enscript highlight=scheme> 158 (domain (%tuple? tup)) 159 (range (list? result)) 160 </enscript> 161 162 transforms a tuple into a list 163 164 ==== tuplefind 165 166 <procedure>(tuplefind tup item compare?)</procedure> 167 168 <enscript highlight=scheme> 169 (domain (%tuple? tup) (procedure? compare?) a two parameter predicate) 170 (range (or (not result) (and (cardinal? result) (< result (%tuplelength tup))))) 171 </enscript> 172 173 checks by comparing with compare? if item is contained in tup 174 175 ==== tupleright 176 177 <procedure>(tupleright tup)</procedure> 178 179 <enscript highlight=scheme> 180 (domain (%tuple? tup) (>= (%tuplelength tup) 2)) 181 </enscript> 182 183 returns the rightmost item of tup 184 185 ==== tupleleft 186 187 <procedure>(tupleleft tup)</procedure> 188 189 <enscript highlight=scheme> 190 (domain (%tuple? tup) (positive? (%tuplelength tup))) 191 </enscript> 192 193 returns the leftmost item of tup 194 195 ==== tupleref 196 197 <procedure>(tupleref tup n)</procedure> 198 199 <enscript highlight=scheme> 200 (domain (%tuple? tup) (cardinal? n) (< n (%tuplelength tup))) 201 </enscript> 202 203 returns the n'th item of tup, counting from zero 204 205 ==== tuplelength 206 207 <procedure>(tuplelength tup)</procedure> 208 209 <enscript highlight=scheme> 210 (domain (%tuple? tup)) 211 (range (cardinal? result)) 212 </enscript> 213 214 returns the number of tuple items 215 216 ==== tuplecopy 217 218 <procedure>(tuplecopy tup . interval)</procedure> 219 220 <enscript highlight=scheme> 221 (domain (%tuple? tup) 222 (<= (length interval) 2) 223 ((listof? cardinal?) interval) 224 (apply <= (append interval (list (%tuplelength tup))))) 225 (range (%tuple? result)) 226 </enscript> 227 228 constructing a subtuple with tup data from interval 229 230 ==== tupleappend 231 232 <procedure>(tupleappend . tups)</procedure> 233 234 <enscript highlight=scheme> 235 (domain ((listof? tuple?) tups)) 236 (range (%tuple? result)) 237 </enscript> 238 239 constructs a new tuple by concatenating several others 240 241 ==== tuplemap 242 243 <procedure>(tuplemap fn tup)</procedure> 244 245 <enscript highlight=scheme> 246 (domain (%tuple? tup) (procedure? fn) a one parameter function) 247 (range (%tuple? result)) 248 </enscript> 249 250 constructs a new tuple by mapping each item of tup with function fn 251 252 ==== list>tuple 253 254 <procedure>(list>tuple lst)</procedure> 255 256 <enscript highlight=scheme> 257 (domain (list? lst)) 258 (range (%tuple? result)) 259 </enscript> 260 261 transforms a list into a tuple 262 263 ==== tuple 264 265 <procedure>(tuple . args)</procedure> 266 267 <enscript highlight=scheme> 268 (domain (true? args)) 269 (range (%tuple? result)) 270 </enscript> 271 272 tuple constructor 273 274 ==== tupleof? 275 276 <procedure>(tupleof? ok?)</procedure> 277 278 <enscript highlight=scheme> 279 (domain (procedure? ok?) ok? is a one parameter predicate) 280 (range (procedure? result) result is a one parameter predicate) 281 </enscript> 282 283 checks, if each tuple item satisfies predicate ok? 284 285 ==== tuple? 286 287 <procedure>(tuple? xpr)</procedure> 288 289 checks if xpr evaluates to a tuple 290 813 <procedure>(single? x)</procedure> 814 815 function (result) 816 817 <enscript highlight=scheme> 818 819 (single? x) 820 #t 821 (boolean? result) 822 823 </enscript> 291 824 292 825 == Requirements 293 826 294 [[ contracts]]827 [[dbc]] 295 828 296 829 == Last update 297 830 298 Aug 02, 2012 831 Jan 31, 2013 299 832 300 833 == Author … … 304 837 == License 305 838 306 Copyright (c) 2012 , Juergen Lorenz839 Copyright (c) 20122013, Juergen Lorenz 307 840 All rights reserved. 308 841 … … 335 868 == Version History 336 869 870 ; 1.0 : dependency on contracts changed to dbc, moduls further split, addition routines 337 871 ; 0.8 : code split into two modules 338 872 ; 0.7 : singlestate and singlestate! renamed to singleref and singleset!
Note: See TracChangeset
for help on using the changeset viewer.