File: maxima_37.html

package info (click to toggle)
maxima 5.21.1-2squeeze
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 94,928 kB
  • ctags: 43,849
  • sloc: lisp: 298,974; fortran: 14,666; perl: 14,325; tcl: 10,494; sh: 4,052; makefile: 2,975; ansic: 471; awk: 24; sed: 7
file content (1056 lines) | stat: -rw-r--r-- 34,878 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on April, 24 2010 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<head>
<title>Maxima 5.21.1 Manual: 37. Lists</title>

<meta name="description" content="Maxima 5.21.1 Manual: 37. Lists">
<meta name="keywords" content="Maxima 5.21.1 Manual: 37. Lists">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
body
{
    color: black;
    background: white; 
    margin-left: 8%;
    margin-right: 13%;
}

h1
{
    margin-left: +8%;
    font-size: 150%;
    font-family: sans-serif
}

h2
{
    font-size: 125%;
    font-family: sans-serif
}

h3
{
    font-size: 100%;
    font-family: sans-serif
}

h2,h3,h4,h5,h6 { margin-left: +4%; }

div.textbox
{
    border: solid;
    border-width: thin;
    /* width: 100%; */
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 2em;
    padding-right: 2em
}

div.titlebox
{
    border: none;
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 2em;
    padding-right: 2em;
    background: rgb(200,255,255);
    font-family: sans-serif
}

div.synopsisbox
{
    border: none;
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 2em;
    padding-right: 2em;
     background: rgb(255,220,255);
    /*background: rgb(200,255,255); */
    /* font-family: fixed */
}

pre.example
{
    border: 1px solid gray;
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 1em;
    padding-right: 1em;
    /* background: rgb(247,242,180); */ /* kind of sandy */
    /* background: rgb(200,255,255); */ /* sky blue */
    background-color: #F1F5F9; /* light blue-gray */
    /* font-family: "Lucida Console", monospace */
}

div.spacerbox
{
    border: none;
    padding-top: 2em;
    padding-bottom: 2em
}

div.image
{
    margin: 0;
    padding: 1em;
    text-align: center;
}

div.categorybox
{
    border: 1px solid gray;
    padding-top: 0px;
    padding-bottom: 0px;
    padding-left: 1em;
    padding-right: 1em;
    background: rgb(247,242,220);
}


-->
</style>

<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Lists"></a>
<a name="SEC163"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="maxima_36.html#SEC162" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC164" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima_36.html#SEC160" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_38.html#SEC166" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 37. Lists </h1>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC164">37.1 Introduction to Lists</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC165">37.2 Functions and Variables for Lists</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<p><a name="Item_003a-Introduction-to-Lists"></a>
</p><hr size="6">
<a name="Introduction-to-Lists"></a>
<a name="SEC164"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC163" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC165" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC163" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC163" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_38.html#SEC166" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 37.1 Introduction to Lists </h2>

<p>Lists are the basic building block for Maxima and Lisp.   All data types
other than arrays, hash tables, numbers are represented as Lisp lists,
These Lisp lists have the form
</p>
<pre class="example">((MPLUS) $A 2)
</pre>

<p>to indicate an expression <code>a+2</code>.   At Maxima level one would see
the infix notation <code>a+2</code>.   Maxima also has lists which are printed
as
</p>
<pre class="example">[1, 2, 7, x+y]
</pre>

<p>for a list with 4 elements.  Internally this corresponds to a Lisp list
of the form
</p>
<pre class="example">((MLIST) 1  2  7  ((MPLUS)  $X $Y ))
</pre>

<p>The flag which denotes the type field of the Maxima expression is a list
itself, since after it has been through the simplifier the list would become
</p>
<pre class="example">((MLIST SIMP) 1 2 7 ((MPLUS SIMP) $X $Y))
</pre>
<p><a name="Item_003a-Functions-and-Variables-for-Lists"></a>
</p><hr size="6">
<a name="Functions-and-Variables-for-Lists"></a>
<a name="SEC165"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC164" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima_38.html#SEC166" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC163" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC163" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_38.html#SEC166" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 37.2 Functions and Variables for Lists </h2>

<p><a name="Item_003a-append"></a>
</p><dl>
<dt><u>Function:</u> <b>append</b><i> (<var>list_1</var>, ..., <var>list_n</var>)</i>
<a name="IDX1301"></a>
</dt>
<dd><p>Returns a single list of the elements of <var>list_1</var> followed
by the elements of <var>list_2</var>, ...  <code>append</code> also works on
general expressions, e.g. <code>append (f(a,b), f(c,d,e));</code> yields
<code>f(a,b,c,d,e)</code>.
</p>
<p>Do <code>example(append);</code> for an example.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-assoc"></a>
</p><dl>
<dt><u>Function:</u> <b>assoc</b><i> (<var>key</var>, <var>list</var>, <var>default</var>)</i>
<a name="IDX1302"></a>
</dt>
<dt><u>Function:</u> <b>assoc</b><i> (<var>key</var>, <var>list</var>)</i>
<a name="IDX1303"></a>
</dt>
<dd><p>This function searches for the <var>key</var> in the left hand side of the input <var>list</var>
of the form <code>[x,y,z,...]</code> where each of the <var>list</var> elements is an expression of
a binary operand and 2 elements.  For example <code>x=1</code>, <code>2^3</code>, <code>[a,b]</code> etc.
The <var>key</var> is checked againts the first operand.  <code>assoc</code> returns the second
operand if the <code>key</code> is found.  If the <code>key</code> is not found it
either returns the <var>default</var> value.  <var>default</var> is optional
and defaults to <code>false</code>.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-atom"></a>
</p><dl>
<dt><u>Function:</u> <b>atom</b><i> (<var>expr</var>)</i>
<a name="IDX1304"></a>
</dt>
<dd><p>Returns <code>true</code> if <var>expr</var> is atomic (i.e. a number, name or string) else
<code>false</code>.  Thus <code>atom(5)</code> is <code>true</code> while <code>atom(a[1])</code> and <code>atom(sin(x))</code> are
<code>false</code> (asuming <code>a[1]</code> and <code>x</code> are unbound).
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
 &middot;
<a href="maxima_95.html#Category_003a-Predicate-functions">Predicate functions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-cons"></a>
</p><dl>
<dt><u>Function:</u> <b>cons</b><i> (<var>expr</var>, <var>list</var>)</i>
<a name="IDX1305"></a>
</dt>
<dd><p>Returns a new list constructed of the element <var>expr</var> as
its first element, followed by the elements of <var>list</var>.  <code>cons</code> also works
on other expressions, e.g. <code>cons(x, f(a,b,c));</code>  -&gt;  <code>f(x,a,b,c)</code>.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-copylist"></a>
</p><dl>
<dt><u>Function:</u> <b>copylist</b><i> (<var>list</var>)</i>
<a name="IDX1306"></a>
</dt>
<dd><p>Returns a copy of the list <var>list</var>.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-create_005flist"></a>
</p><dl>
<dt><u>Function:</u> <b>create_list</b><i> (<var>form</var>, <var>x_1</var>, <var>list_1</var>, ..., <var>x_n</var>, <var>list_n</var>)</i>
<a name="IDX1307"></a>
</dt>
<dd><p>Create a list by evaluating <var>form</var> with <var>x_1</var> bound to
each element of <var>list_1</var>, and for each such binding bind <var>x_2</var>
to each element of <var>list_2</var>, ....
The number of elements in the result will be
the product of the number of elements in each list.
Each variable <var>x_i</var> must actually be a symbol - it will not be evaluated.
The list arguments will be evaluated once at the beginning of the
iteration.
</p>
<pre class="example">(%i1) create_list(x^i,i,[1,3,7]);
                 3   7
(%o1)       [x, x , x ]
</pre>

<p>With a double iteration:
</p>
<pre class="example">(%i1) create_list([i,j],i,[a,b],j,[e,f,h]);
(%o1) [[a, e], [a, f], [a, h], [b, e], [b, f], [b, h]]
</pre>
<p>Instead of <var>list_i</var> two args may be supplied each of which should
evaluate to a number.  These will be the inclusive lower and
upper bounds for the iteration.
</p>
<pre class="example">(%i1) create_list([i,j],i,[1,2,3],j,1,i);
(%o1) [[1, 1], [2, 1], [2, 2], [3, 1], [3, 2], [3, 3]]
</pre>
<p>Note that the limits or list for the <code>j</code> variable can
depend on the current value of <code>i</code>.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-delete"></a>
</p><dl>
<dt><u>Function:</u> <b>delete</b><i> (<var>expr_1</var>, <var>expr_2</var>)</i>
<a name="IDX1308"></a>
</dt>
<dt><u>Function:</u> <b>delete</b><i> (<var>expr_1</var>, <var>expr_2</var>, <var>n</var>)</i>
<a name="IDX1309"></a>
</dt>
<dd><p><code>delete(<var>expr_1</var>, <var>expr_2</var>)</code>
removes from <var>expr_2</var> any arguments of its top-level operator
which are the same (as determined by &quot;=&quot;) as <var>expr_1</var>.
Note that &quot;=&quot; tests for formal equality, not equivalence.
Note also that arguments of subexpressions are not affected.
</p>
<p><var>expr_1</var> may be an atom or a non-atomic expression.
<var>expr_2</var> may be any non-atomic expression.
<code>delete</code> returns a new expression;
it does not modify <var>expr_2</var>.
</p>
<p><code>delete(<var>expr_1</var>, <var>expr_2</var>, <var>n</var>)</code>
removes from <var>expr_2</var> the first <var>n</var> arguments of the top-level operator
which are the same as <var>expr_1</var>.
If there are fewer than <var>n</var> such arguments,
then all such arguments are removed.
</p>
<p>Examples:
</p>
<p>Removing elements from a list.
</p>
<pre class="example">(%i1) delete (y, [w, x, y, z, z, y, x, w]);
(%o1)                  [w, x, z, z, x, w]
</pre>
<p>Removing terms from a sum.
</p>
<pre class="example">(%i1) delete (sin(x), x + sin(x) + y);
(%o1)                         y + x
</pre>
<p>Removing factors from a product.
</p>
<pre class="example">(%i1) delete (u - x, (u - w)*(u - x)*(u - y)*(u - z));
(%o1)                (u - w) (u - y) (u - z)
</pre>
<p>Removing arguments from an arbitrary expression.
</p>
<pre class="example">(%i1) delete (a, foo (a, b, c, d, a));
(%o1)                     foo(b, c, d)
</pre>
<p>Limit the number of removed arguments.
</p>
<pre class="example">(%i1) delete (a, foo (a, b, a, c, d, a), 2);
(%o1)                    foo(b, c, d, a)
</pre>
<p>Whether arguments are the same as <var>expr_1</var> is determined by &quot;=&quot;.
Arguments which are <code>equal</code> but not &quot;=&quot; are not removed.
</p>
<pre class="example">(%i1) [is (equal (0, 0)), is (equal (0, 0.0)), is (equal (0, 0b0))];

`rat' replaced 0.0 by 0/1 = 0.0
`rat' replaced 0.0B0 by 0/1 = 0.0B0
(%o1)                  [true, true, true]
(%i2) [is (0 = 0), is (0 = 0.0), is (0 = 0b0)];
(%o2)                 [true, false, false]
(%i3) delete (0, [0, 0.0, 0b0]);
(%o3)                     [0.0, 0.0b0]
(%i4) is (equal ((x + y)*(x - y), x^2 - y^2));
(%o4)                         true
(%i5) is ((x + y)*(x - y) = x^2 - y^2);
(%o5)                         false
(%i6) delete ((x + y)*(x - y), [(x + y)*(x - y), x^2 - y^2]);
                              2    2
(%o6)                       [x  - y ]
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-eighth"></a>
</p><dl>
<dt><u>Function:</u> <b>eighth</b><i> (<var>expr</var>)</i>
<a name="IDX1310"></a>
</dt>
<dd><p>Returns the 8'th item of expression or list <var>expr</var>.
See <code>first</code> for more details.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-endcons"></a>
</p><dl>
<dt><u>Function:</u> <b>endcons</b><i> (<var>expr</var>, <var>list</var>)</i>
<a name="IDX1311"></a>
</dt>
<dd><p>Returns a new list consisting of the elements of
<code>list</code> followed by <var>expr</var>.  <code>endcons</code> also works on general expressions, e.g.
<code>endcons(x, f(a,b,c));</code>  -&gt;  <code>f(a,b,c,x)</code>.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-fifth"></a>
</p><dl>
<dt><u>Function:</u> <b>fifth</b><i> (<var>expr</var>)</i>
<a name="IDX1312"></a>
</dt>
<dd><p>Returns the 5'th item of expression or list <var>expr</var>.
See <code>first</code> for more details.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-first"></a>
</p><dl>
<dt><u>Function:</u> <b>first</b><i> (<var>expr</var>)</i>
<a name="IDX1313"></a>
</dt>
<dd><p>Returns the first part of <var>expr</var> which may result in the first
element of a list, the first row of a matrix, the first term of a sum,
etc.  Note that <code>first</code> and its related functions, <code>rest</code> and <code>last</code>, work
on the form of <var>expr</var> which is displayed not the form which is typed on
input.  If the variable <code>inflag</code> is set to <code>true</code> however, these
functions will look at the internal form of <var>expr</var>.  Note that the
simplifier re-orders expressions.  Thus <code>first(x+y)</code> will be <code>x</code> if <code>inflag</code>
is <code>true</code> and <code>y</code> if <code>inflag</code> is <code>false</code> (<code>first(y+x)</code> gives the same
results).  The functions <code>second</code> .. <code>tenth</code> yield the second through the
tenth part of their input argument.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-fourth"></a>
</p><dl>
<dt><u>Function:</u> <b>fourth</b><i> (<var>expr</var>)</i>
<a name="IDX1314"></a>
</dt>
<dd><p>Returns the 4'th item of expression or list <var>expr</var>.
See <code>first</code> for more details.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-get"></a>
</p><dl>
<dt><u>Function:</u> <b>get</b><i> (<var>a</var>, <var>i</var>)</i>
<a name="IDX1315"></a>
</dt>
<dd><p>Retrieves the user property indicated by <var>i</var> associated with
atom <var>a</var> or returns <code>false</code> if a doesn't have property <var>i</var>.
</p>
<p><code>get</code> evaluates its arguments.
</p>
<pre class="example">(%i1) put (%e, 'transcendental, 'type);
(%o1)                    transcendental
(%i2) put (%pi, 'transcendental, 'type)$
(%i3) put (%i, 'algebraic, 'type)$
(%i4) typeof (expr) := block ([q],
        if numberp (expr)
        then return ('algebraic),
        if not atom (expr)
        then return (maplist ('typeof, expr)),
        q: get (expr, 'type),
        if q=false
        then errcatch (error(expr,&quot;is not numeric.&quot;)) else q)$
(%i5) typeof (2*%e + x*%pi);
x is not numeric.
(%o5)  [[transcendental, []], [algebraic, transcendental]]
(%i6) typeof (2*%e + %pi);
(%o6)     [transcendental, [algebraic, transcendental]]

</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Declarations-and-inferences">Declarations and inferences</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-join"></a>
</p><dl>
<dt><u>Function:</u> <b>join</b><i> (<var>l</var>, <var>m</var>)</i>
<a name="IDX1316"></a>
</dt>
<dd><p>Creates a new list containing the elements of lists <var>l</var> and <var>m</var>, interspersed.
The result has elements <code>[<var>l</var>[1], <var>m</var>[1], <var>l</var>[2], <var>m</var>[2], ...]</code>.
The lists <var>l</var> and <var>m</var> may contain any type of elements.
</p>
<p>If the lists are different lengths, <code>join</code> ignores elements of the longer list.
</p>
<p>Maxima complains if <var>l</var> or <var>m</var> is not a list.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) L1: [a, sin(b), c!, d - 1];
(%o1)                [a, sin(b), c!, d - 1]
(%i2) join (L1, [1, 2, 3, 4]);
(%o2)          [a, 1, sin(b), 2, c!, 3, d - 1, 4]
(%i3) join (L1, [aa, bb, cc, dd, ee, ff]);
(%o3)        [a, aa, sin(b), bb, c!, cc, d - 1, dd]
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-last"></a>
</p><dl>
<dt><u>Function:</u> <b>last</b><i> (<var>expr</var>)</i>
<a name="IDX1317"></a>
</dt>
<dd><p>Returns the last part (term, row, element, etc.) of the <var>expr</var>.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-length"></a>
</p><dl>
<dt><u>Function:</u> <b>length</b><i> (<var>expr</var>)</i>
<a name="IDX1318"></a>
</dt>
<dd><p>Returns (by default) the number of parts in the external
(displayed) form of <var>expr</var>.  For lists this is the number of elements,
for matrices it is the number of rows, and for sums it is the number
of terms (see <code>dispform</code>).
</p>
<p>The <code>length</code> command is affected by the
<code>inflag</code> switch.  So, e.g. <code>length(a/(b*c));</code> gives 2 if
<code>inflag</code> is <code>false</code> (Assuming <code>exptdispflag</code> is <code>true</code>), but 3 if <code>inflag</code> is
<code>true</code> (the internal representation is essentially <code>a*b^-1*c^-1</code>).
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-listarith"></a>
</p><dl>
<dt><u>Option variable:</u> <b>listarith</b>
<a name="IDX1319"></a>
</dt>
<dd><p>default value: <code>true</code> - if <code>false</code> causes any arithmetic operations
with lists to be suppressed; when <code>true</code>, list-matrix operations are
contagious causing lists to be converted to matrices yielding a result
which is always a matrix.  However, list-list operations should return
lists.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Global-flags">Global flags</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-listp"></a>
</p><dl>
<dt><u>Function:</u> <b>listp</b><i> (<var>expr</var>)</i>
<a name="IDX1320"></a>
</dt>
<dd><p>Returns <code>true</code> if <var>expr</var> is a list else <code>false</code>.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Predicate-functions">Predicate functions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-makelist"></a>
</p><dl>
<dt><u>Function:</u> <b>makelist</b><i> (<var>expr</var>, <var>i</var>, <var>i_0</var>, <var>i_1</var>)</i>
<a name="IDX1321"></a>
</dt>
<dt><u>Function:</u> <b>makelist</b><i> (<var>expr</var>, <var>x</var>, <var>list</var>)</i>
<a name="IDX1322"></a>
</dt>
<dd><p>Constructs and returns a list,
each element of which is generated from <var>expr</var>.
</p>
<p><code>makelist (<var>expr</var>, <var>i</var>, <var>i_0</var>, <var>i_1</var>)</code> returns a list,
the <code>j</code>'th element of which is equal to <code>ev (<var>expr</var>, <var>i</var>=j)</code>
for <code>j</code> equal to <var>i_0</var> through <var>i_1</var>.
</p>
<p><code>makelist (<var>expr</var>, <var>x</var>, <var>list</var>)</code> returns a list,
the <code>j</code>'th element of which is equal to <code>ev (<var>expr</var>, <var>x</var>=<var>list</var>[j])</code>
for <code>j</code> equal to 1 through <code>length (<var>list</var>)</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) makelist(concat(x,i),i,1,6);
(%o1)               [x1, x2, x3, x4, x5, x6]
(%i2) makelist(x=y,y,[a,b,c]);
(%o2)                 [x = a, x = b, x = c]

</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-member"></a>
</p><dl>
<dt><u>Function:</u> <b>member</b><i> (<var>expr_1</var>, <var>expr_2</var>)</i>
<a name="IDX1323"></a>
</dt>
<dd><p>Returns <code>true</code> if <code>is(<var>expr_1</var> = <var>a</var>)</code>
for some element <var>a</var> in <code>args(<var>expr_2</var>)</code>,
otherwise returns <code>false</code>.
</p>
<p><code>expr_2</code> is typically a list,
in which case <code>args(<var>expr_2</var>) = <var>expr_2</var></code>
and <code>is(<var>expr_1</var> = <var>a</var>)</code> for some element <var>a</var> in <code>expr_2</code> is the test.
</p>
<p><code>member</code> does not inspect parts of the arguments of <code>expr_2</code>,
so it may return <code>false</code> even if <code>expr_1</code> is a part of some argument of <code>expr_2</code>.
</p>
<p>See also <code>elementp</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) member (8, [8, 8.0, 8b0]);
(%o1)                         true
(%i2) member (8, [8.0, 8b0]);
(%o2)                         false
(%i3) member (b, [a, b, c]);
(%o3)                         true
(%i4) member (b, [[a, b], [b, c]]);
(%o4)                         false
(%i5) member ([b, c], [[a, b], [b, c]]);
(%o5)                         true
(%i6) F (1, 1/2, 1/4, 1/8);
                               1  1  1
(%o6)                     F(1, -, -, -)
                               2  4  8
(%i7) member (1/8, %);
(%o7)                         true
(%i8) member (&quot;ab&quot;, [&quot;aa&quot;, &quot;ab&quot;, sin(1), a + b]);
(%o8)                         true
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
 &middot;
<a href="maxima_95.html#Category_003a-Predicate-functions">Predicate functions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-ninth"></a>
</p><dl>
<dt><u>Function:</u> <b>ninth</b><i> (<var>expr</var>)</i>
<a name="IDX1324"></a>
</dt>
<dd><p>Returns the 9'th item of expression or list <var>expr</var>.
See <code>first</code> for more details.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-unique"></a>
</p><dl>
<dt><u>Function:</u> <b>unique</b><i> (<var>L</var>)</i>
<a name="IDX1325"></a>
</dt>
<dd><p>Returns the unique elements of the list <var>L</var>.
</p>
<p>When all the elements of <var>L</var> are unique,
<code>unique</code> returns a shallow copy of <var>L</var>,
not <var>L</var> itself.
</p>
<p>If <var>L</var> is not a list, <code>unique</code> returns <var>L</var>.
</p>
<p>Example:
</p>
<pre class="example">(%i1) unique ([1, %pi, a + b, 2, 1, %e, %pi, a + b, [1]]);
(%o1)              [1, 2, %e, %pi, [1], b + a]
</pre></dd></dl>

<p><a name="Item_003a-rest"></a>
</p><dl>
<dt><u>Function:</u> <b>rest</b><i> (<var>expr</var>, <var>n</var>)</i>
<a name="IDX1326"></a>
</dt>
<dt><u>Function:</u> <b>rest</b><i> (<var>expr</var>)</i>
<a name="IDX1327"></a>
</dt>
<dd><p>Returns <var>expr</var> with its first <var>n</var> elements removed if <var>n</var> is
positive and its last <code>- <var>n</var></code> elements removed if <var>n</var> is negative.  If <var>n</var> is 1
it may be omitted.  <var>expr</var> may be a list, matrix, or other expression.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-reverse"></a>
</p><dl>
<dt><u>Function:</u> <b>reverse</b><i> (<var>list</var>)</i>
<a name="IDX1328"></a>
</dt>
<dd><p>Reverses the order of the members of the <var>list</var> (not
the members themselves).  <code>reverse</code> also works on general expressions,
e.g.  <code>reverse(a=b);</code> gives <code>b=a</code>.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-second"></a>
</p><dl>
<dt><u>Function:</u> <b>second</b><i> (<var>expr</var>)</i>
<a name="IDX1329"></a>
</dt>
<dd><p>Returns the 2'nd item of expression or list <var>expr</var>.
See <code>first</code> for more details.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-seventh"></a>
</p><dl>
<dt><u>Function:</u> <b>seventh</b><i> (<var>expr</var>)</i>
<a name="IDX1330"></a>
</dt>
<dd><p>Returns the 7'th item of expression or list <var>expr</var>.
See <code>first</code> for more details.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-sixth"></a>
</p><dl>
<dt><u>Function:</u> <b>sixth</b><i> (<var>expr</var>)</i>
<a name="IDX1331"></a>
</dt>
<dd><p>Returns the 6'th item of expression or list <var>expr</var>.
See <code>first</code> for more details.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-sublist_005findices"></a>
</p><dl>
<dt><u>Function:</u> <b>sublist_indices</b><i> (<var>L</var>, <var>P</var>)</i>
<a name="IDX1332"></a>
</dt>
<dd><p>Returns the indices of the elements <code>x</code> of the list <var>L</var> for which
the predicate <code>maybe(<var>P</var>(x))</code> returns <code>true</code>;
this excludes <code>unknown</code> as well as <code>false</code>.
<var>P</var> may be the name of a function or a lambda expression.
<var>L</var> must be a literal list.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) sublist_indices ('[a, b, b, c, 1, 2, b, 3, b],
                       lambda ([x], x='b));
(%o1)                     [2, 3, 7, 9]
(%i2) sublist_indices ('[a, b, b, c, 1, 2, b, 3, b], symbolp);
(%o2)                  [1, 2, 3, 4, 7, 9]
(%i3) sublist_indices ([1 &gt; 0, 1 &lt; 0, 2 &lt; 1, 2 &gt; 1, 2 &gt; 0],
                       identity);
(%o3)                       [1, 4, 5]
(%i4) assume (x &lt; -1);
(%o4)                       [x &lt; - 1]
(%i5) map (maybe, [x &gt; 0, x &lt; 0, x &lt; -2]);
(%o5)                [false, true, unknown]
(%i6) sublist_indices ([x &gt; 0, x &lt; 0, x &lt; -2], identity);
(%o6)                          [2]
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-tenth"></a>
</p><dl>
<dt><u>Function:</u> <b>tenth</b><i> (<var>expr</var>)</i>
<a name="IDX1333"></a>
</dt>
<dd><p>Returns the 10'th item of expression or list <var>expr</var>.
See <code>first</code> for more details.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>

<p><a name="Item_003a-third"></a>
</p><dl>
<dt><u>Function:</u> <b>third</b><i> (<var>expr</var>)</i>
<a name="IDX1334"></a>
</dt>
<dd><p>Returns the 3'rd item of expression or list <var>expr</var>.
See <code>first</code> for more details.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
 &middot;
<a href="maxima_95.html#Category_003a-Expressions">Expressions</a>
</p>
</div>

</dd></dl>


<p><a name="Item_003a-Sets"></a>
</p><hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC163" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima_38.html#SEC166" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated by <em>Robert Dodier</em> on <em>April, 24 2010</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 </font>
 <br>

</p>
</body>
</html>