passagemath-repl 10.5.27__py3-none-any.whl → 10.5.29__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/kernel.json +1 -0
  2. passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/logo-64x64.png +0 -0
  3. passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/logo.svg +352 -0
  4. {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/METADATA +38 -13
  5. {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/RECORD +95 -24
  6. {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/top_level.txt +1 -0
  7. sage/ext_data/all__sagemath_repl.py +1 -0
  8. sage/interfaces/all__sagemath_repl.py +1 -0
  9. sage/repl/ipython_kernel/install.py +6 -8
  10. sage/tests/books/__init__.py +2 -0
  11. sage/tests/books/computational-mathematics-with-sagemath/__init__.py +1 -0
  12. sage/tests/books/computational-mathematics-with-sagemath/calculus_doctest.py +549 -0
  13. sage/tests/books/computational-mathematics-with-sagemath/combinat_doctest.py +1053 -0
  14. sage/tests/books/computational-mathematics-with-sagemath/domaines_doctest.py +443 -0
  15. sage/tests/books/computational-mathematics-with-sagemath/float_doctest.py +477 -0
  16. sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py +254 -0
  17. sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py +418 -0
  18. sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py +290 -0
  19. sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py +454 -0
  20. sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py +421 -0
  21. sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py +234 -0
  22. sage/tests/books/computational-mathematics-with-sagemath/mpoly_doctest.py +560 -0
  23. sage/tests/books/computational-mathematics-with-sagemath/nonlinear_doctest.py +490 -0
  24. sage/tests/books/computational-mathematics-with-sagemath/numbertheory_doctest.py +155 -0
  25. sage/tests/books/computational-mathematics-with-sagemath/polynomes_doctest.py +405 -0
  26. sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py +180 -0
  27. sage/tests/books/computational-mathematics-with-sagemath/programmation_doctest.py +662 -0
  28. sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py +392 -0
  29. sage/tests/books/computational-mathematics-with-sagemath/sol/__init__.py +1 -0
  30. sage/tests/books/computational-mathematics-with-sagemath/sol/calculus_doctest.py +264 -0
  31. sage/tests/books/computational-mathematics-with-sagemath/sol/combinat_doctest.py +217 -0
  32. sage/tests/books/computational-mathematics-with-sagemath/sol/domaines_doctest.py +59 -0
  33. sage/tests/books/computational-mathematics-with-sagemath/sol/float_doctest.py +141 -0
  34. sage/tests/books/computational-mathematics-with-sagemath/sol/graphique_doctest.py +105 -0
  35. sage/tests/books/computational-mathematics-with-sagemath/sol/graphtheory_doctest.py +53 -0
  36. sage/tests/books/computational-mathematics-with-sagemath/sol/integration_doctest.py +56 -0
  37. sage/tests/books/computational-mathematics-with-sagemath/sol/linalg_doctest.py +56 -0
  38. sage/tests/books/computational-mathematics-with-sagemath/sol/linsolve_doctest.py +25 -0
  39. sage/tests/books/computational-mathematics-with-sagemath/sol/lp_doctest.py +47 -0
  40. sage/tests/books/computational-mathematics-with-sagemath/sol/mpoly_doctest.py +115 -0
  41. sage/tests/books/computational-mathematics-with-sagemath/sol/nonlinear_doctest.py +111 -0
  42. sage/tests/books/computational-mathematics-with-sagemath/sol/numbertheory_doctest.py +167 -0
  43. sage/tests/books/computational-mathematics-with-sagemath/sol/polynomes_doctest.py +107 -0
  44. sage/tests/books/computational-mathematics-with-sagemath/sol/recequadiff_doctest.py +58 -0
  45. sage/tests/books/judson-abstract-algebra/__init__.py +1 -0
  46. sage/tests/books/judson-abstract-algebra/actions-sage-exercises.py +51 -0
  47. sage/tests/books/judson-abstract-algebra/actions-sage.py +173 -0
  48. sage/tests/books/judson-abstract-algebra/algcodes-sage.py +130 -0
  49. sage/tests/books/judson-abstract-algebra/boolean-sage.py +269 -0
  50. sage/tests/books/judson-abstract-algebra/cosets-sage-exercises.py +87 -0
  51. sage/tests/books/judson-abstract-algebra/cosets-sage.py +170 -0
  52. sage/tests/books/judson-abstract-algebra/crypt-sage.py +151 -0
  53. sage/tests/books/judson-abstract-algebra/cyclic-sage.py +450 -0
  54. sage/tests/books/judson-abstract-algebra/domains-sage.py +163 -0
  55. sage/tests/books/judson-abstract-algebra/fields-sage.py +299 -0
  56. sage/tests/books/judson-abstract-algebra/finite-sage.py +108 -0
  57. sage/tests/books/judson-abstract-algebra/galois-sage.py +484 -0
  58. sage/tests/books/judson-abstract-algebra/groups-sage.py +280 -0
  59. sage/tests/books/judson-abstract-algebra/homomorph-sage-exercises.py +65 -0
  60. sage/tests/books/judson-abstract-algebra/homomorph-sage.py +200 -0
  61. sage/tests/books/judson-abstract-algebra/integers-sage.py +197 -0
  62. sage/tests/books/judson-abstract-algebra/isomorph-sage.py +172 -0
  63. sage/tests/books/judson-abstract-algebra/normal-sage.py +133 -0
  64. sage/tests/books/judson-abstract-algebra/permute-sage.py +319 -0
  65. sage/tests/books/judson-abstract-algebra/poly-sage.py +300 -0
  66. sage/tests/books/judson-abstract-algebra/rings-sage.py +413 -0
  67. sage/tests/books/judson-abstract-algebra/sets-sage.py +163 -0
  68. sage/tests/books/judson-abstract-algebra/struct-sage.py +63 -0
  69. sage/tests/books/judson-abstract-algebra/sylow-sage.py +250 -0
  70. sage/tests/books/judson-abstract-algebra/vect-sage-exercises.py +48 -0
  71. sage/tests/books/judson-abstract-algebra/vect-sage.py +211 -0
  72. sage/tests/memcheck/__init__.py +1 -0
  73. sage/tests/memcheck/run_tests.py +25 -0
  74. sage/tests/memcheck/run_tests_in_valgrind.py +36 -0
  75. sage/tests/memcheck/symbolic_expression.py +12 -0
  76. sage/tests/memcheck/verify_no_leak.py +28 -0
  77. sage/tests/all.py +0 -0
  78. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-cachegrind +0 -0
  79. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-callgrind +0 -0
  80. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-cleaner +0 -0
  81. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-coverage +0 -0
  82. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-eval +0 -0
  83. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-fixdoctests +0 -0
  84. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-inline-fortran +0 -0
  85. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-ipynb2rst +0 -0
  86. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-ipython +0 -0
  87. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-massif +0 -0
  88. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-notebook +0 -0
  89. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-omega +0 -0
  90. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-preparse +0 -0
  91. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-run +0 -0
  92. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-run-cython +0 -0
  93. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-runtests +0 -0
  94. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-startuptime.py +0 -0
  95. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-valgrind +0 -0
  96. {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/WHEEL +0 -0
@@ -0,0 +1,662 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ This file (./programmation_doctest.sage) was *autogenerated* from ./programmation.tex,
4
+ with sagetex.sty version 2011/05/27 v2.3.1.
5
+ It contains the contents of all the sageexample environments from this file.
6
+ You should be able to doctest this file with:
7
+ sage -t ./programmation_doctest.sage
8
+ It is always safe to delete this file; it is not used in typesetting your
9
+ document.
10
+
11
+ Sage example in ./programmation.tex, line 118::
12
+
13
+ sage: 2*3; 3*4; 4*5 # one comment, 3 results
14
+ 6
15
+ 12
16
+ 20
17
+
18
+ Sage example in ./programmation.tex, line 137::
19
+
20
+ sage: 123 + \
21
+ ....: 345
22
+ 468
23
+
24
+ Sage example in ./programmation.tex, line 201::
25
+
26
+ sage: import keyword; sorted(keyword.kwlist)
27
+ [...'and', 'as', 'assert', ..., 'class', 'continue', 'def', 'del'...]
28
+
29
+ Sage example in ./programmation.tex, line 338::
30
+
31
+ sage: y = 3; y = 3 * y + 1; y = 3 * y + 1; y
32
+ 31
33
+
34
+ Sage example in ./programmation.tex, line 368::
35
+
36
+ sage: a, b = 10, 20 # (a, b) = (10, 20) and [10, 20] are also possible
37
+ sage: a, b = b, a
38
+ sage: a, b
39
+ (20, 10)
40
+
41
+ Sage example in ./programmation.tex, line 382::
42
+
43
+ sage: temp = a; a = b; b = temp # equivalent to: a, b = b, a
44
+
45
+ Sage example in ./programmation.tex, line 391::
46
+
47
+ sage: x, y = var('x, y'); a = x ; b = y
48
+ sage: a, b
49
+ (x, y)
50
+ sage: a = a + b ; b = a - b ; a = a - b
51
+ sage: a, b
52
+ (y, x)
53
+
54
+ Sage example in ./programmation.tex, line 416::
55
+
56
+ sage: 2 + 2 == 2^2, 3 * 3 == 3^3
57
+ (True, False)
58
+
59
+ Sage example in ./programmation.tex, line 483::
60
+
61
+ sage: for k in [1..5]:
62
+ ....: print(7*k) # block containing a single instruction
63
+ 7
64
+ 14
65
+ 21
66
+ 28
67
+ 35
68
+
69
+ Sage example in ./programmation.tex, line 687::
70
+
71
+ sage: S = 0 ; k = 0 # The sum S starts to 0
72
+ sage: while e^k <= 10^6: # e^13 <= 10^6 < e^14
73
+ ....: S = S + k^2 # accumulates the squares k^2
74
+ ....: k = k + 1
75
+ sage: S
76
+ 819
77
+
78
+ Sage example in ./programmation.tex, line 734::
79
+
80
+ sage: x = 10^4; u = 1; n = 0 # invariant: u = 2^n
81
+ sage: while u <= x: n = n+1; u = 2*u # or n += 1; u *= 2
82
+ sage: n
83
+ 14
84
+
85
+ Sage example in ./programmation.tex, line 880::
86
+
87
+ sage: U = 1.0 # or U = 1. or U = 1.000
88
+ sage: for n in [1..20]:
89
+ ....: U = 1 / (1 + U^2)
90
+ sage: U
91
+ 0.682360434761105
92
+
93
+ Sage example in ./programmation.tex, line 942::
94
+
95
+ sage: S = 0 ; n = 10
96
+ sage: for k in [1..n]:
97
+ ....: S = S + (2*k) * (2*k+1)
98
+ sage: S
99
+ 1650
100
+
101
+ Sage example in ./programmation.tex, line 961::
102
+
103
+ sage: n, k = var('n, k') ; res = sum(2*k*(2*k+1), k, 1, n)
104
+ sage: res, factor(res) # result expanded, factorised
105
+ (4/3*n^3 + 3*n^2 + 5/3*n, 1/3*(4*n + 5)*(n + 1)*n)
106
+
107
+ Sage example in ./programmation.tex, line 1074::
108
+
109
+ sage: U = 2.0; V = 50.0
110
+ sage: while V-U >= 1.0e-6: # 1.0e-6 stands for 1.0*10^-6
111
+ ....: temp = U
112
+ ....: U = 2 * U * V / (U + V)
113
+ ....: V = (temp + V) / 2
114
+ sage: U, V
115
+ (9.99999999989256, 10.0000000001074)
116
+
117
+ Sage example in ./programmation.tex, line 1166::
118
+
119
+ sage: U = 0.0 # the sum S0 is empty, of value zero
120
+ sage: V = -1.0 # S1 = -1/1^3
121
+ sage: n = 0 # U and V contain S(2n) and S(2n+1)
122
+ sage: while U-V >= 1.0e-6:
123
+ ....: n = n+1 # n += 1 is equivalent
124
+ ....: U = V + 1/(2*n)^3 # going from S(2n-1) to S(2n)
125
+ ....: V = U - 1/(2*n+1)^3 # going from S(2n) to S(2n+1)
126
+ sage: V, U
127
+ (-0.901543155458595, -0.901542184868447)
128
+
129
+ Sage example in ./programmation.tex, line 1404::
130
+
131
+ sage: u = 6 ; n = 0
132
+ sage: while u != 1:
133
+ ....: if u % 2 == 0: # the operator % yields the remainder
134
+ ....: u = u//2 # //: Euclidean division quotient
135
+ ....: else:
136
+ ....: u = 3*u+1
137
+ ....: n = n+1
138
+ sage: n
139
+ 8
140
+
141
+ Sage example in ./programmation.tex, line 1508::
142
+
143
+ sage: def fct2 (x, y):
144
+ ....: return x^2 + y^2
145
+ sage: a = var('a')
146
+ sage: fct2 (a, 2*a)
147
+ 5*a^2
148
+
149
+ Sage example in ./programmation.tex, line 1557::
150
+
151
+ sage: def foo (u):
152
+ ....: t = u^2
153
+ ....: return t*(t+1)
154
+ sage: t = 1 ; u = 2
155
+ sage: foo(3), t, u
156
+ (90, 1, 2)
157
+
158
+ Sage example in ./programmation.tex, line 1570::
159
+
160
+ sage: a = b = 1
161
+ sage: def f(): global a; a = b = 2
162
+ sage: f(); a, b
163
+ (2, 1)
164
+
165
+ Sage example in ./programmation.tex, line 1591::
166
+
167
+ sage: def AHmean (u, v):
168
+ ....: u, v = min(u, v), max(u, v)
169
+ ....: while v-u > 2.0e-8:
170
+ ....: u, v = 2*u*v/(u+v), (u+v)/2
171
+ ....: return (u+v) / 2
172
+
173
+ Sage example in ./programmation.tex, line 1604::
174
+
175
+ sage: AHmean (1., 2.)
176
+ 1.41421356237309
177
+ sage: AHmean # corresponds to a function
178
+ <function AHmean at ...>
179
+
180
+ Sage example in ./programmation.tex, line 1687::
181
+
182
+ sage: def fact1 (n):
183
+ ....: res = 1
184
+ ....: for k in [1..n]: res = res*k
185
+ ....: return res
186
+
187
+ Sage example in ./programmation.tex, line 1693::
188
+
189
+ sage: def fact2 (n):
190
+ ....: if n == 0: return 1
191
+ ....: else: return n*fact2(n-1)
192
+
193
+ Sage example in ./programmation.tex, line 1728::
194
+
195
+ sage: def fib1 (n):
196
+ ....: if n == 0 or n == 1: return n
197
+ ....: else:
198
+ ....: U = 0 ; V = 1 # the initial terms u0 and u1
199
+ ....: for k in [2..n]: W = U+V ; U = V ; V = W
200
+ ....: return V
201
+ sage: fib1(8)
202
+ 21
203
+
204
+ Sage example in ./programmation.tex, line 1769::
205
+
206
+ sage: def fib2 (n):
207
+ ....: if 0 <= n <= 1: return n # for n = 0 or n = 1
208
+ ....: else: return fib2(n-1) + fib2(n-2)
209
+
210
+ Sage example in ./programmation.tex, line 1857::
211
+
212
+ sage: a = 2; n = 6; res = 1 # 1 is the product neutral element
213
+ sage: for k in [1..n]: res = res*a
214
+ sage: res # the value of res is 2^6
215
+ 64
216
+
217
+ Sage example in ./programmation.tex, line 1958::
218
+
219
+ sage: def pow1 (a, n):
220
+ ....: if n == 0: return 1
221
+ ....: elif n % 2 == 0: b = pow1 (a, n//2); return b*b
222
+ ....: else: return a * pow1(a, n-1)
223
+
224
+ Sage example in ./programmation.tex, line 1968::
225
+
226
+ sage: pow1 (2, 11) # result is 2^11
227
+ 2048
228
+
229
+ Sage example in ./programmation.tex, line 2010::
230
+
231
+ sage: def pow2 (u, k):
232
+ ....: v = 1
233
+ ....: while k != 0:
234
+ ....: if k % 2 == 0: u = u*u ; k = k//2
235
+ ....: else: v = v*u ; k = k-1
236
+ ....: return v
237
+
238
+ Sage example in ./programmation.tex, line 2022::
239
+
240
+ sage: pow2 (2, 10) # result is 2^10
241
+ 1024
242
+
243
+ Sage example in ./programmation.tex, line 2109::
244
+
245
+ sage: def fib3 (n):
246
+ ....: A = matrix ([[0, 1], [1, 1]]) ; X0 = vector ([0, 1])
247
+ ....: return (A^n*X0)[0]
248
+
249
+ Sage example in ./programmation.tex, line 2114::
250
+
251
+ sage: def fib4 (n):
252
+ ....: return (matrix([[0,1], [1,1]])^n * vector([0,1]))[0]
253
+
254
+ Sage example in ./programmation.tex, line 2195::
255
+
256
+ sage: for k in [1..6]: print('%2d^4 = %4d' % (k, k^4))
257
+ 1^4 = 1
258
+ 2^4 = 16
259
+ 3^4 = 81
260
+ 4^4 = 256
261
+ 5^4 = 625
262
+ 6^4 = 1296
263
+
264
+ Sage example in ./programmation.tex, line 2274::
265
+
266
+ sage: L = [10, 20, 30]
267
+ sage: L
268
+ [10, 20, 30]
269
+ sage: [] # [] is the empty list
270
+ []
271
+
272
+ Sage example in ./programmation.tex, line 2299::
273
+
274
+ sage: L[1], len(L), len([])
275
+ (20, 3, 0)
276
+
277
+ Sage example in ./programmation.tex, line 2309::
278
+
279
+ sage: L[2] = 33
280
+ sage: L
281
+ [10, 20, 33]
282
+
283
+ Sage example in ./programmation.tex, line 2318::
284
+
285
+ sage: L = [11, 22, 33]
286
+ sage: L[-1], L[-2], L[-3]
287
+ (33, 22, 11)
288
+
289
+ Sage example in ./programmation.tex, line 2336::
290
+
291
+ sage: L = [0, 11, 22, 33, 44, 55]
292
+ sage: L[2:4]
293
+ [22, 33]
294
+ sage: L[-4:4]
295
+ [22, 33]
296
+ sage: L[2:-2]
297
+ [22, 33]
298
+ sage: L[:4]
299
+ [0, 11, 22, 33]
300
+ sage: L[4:]
301
+ [44, 55]
302
+
303
+ Sage example in ./programmation.tex, line 2359::
304
+
305
+ sage: L = [0, 11, 22, 33, 44, 55, 66, 77]
306
+ sage: L[2:6] = [12, 13, 14] # substitutes [22, 33, 44, 55]
307
+
308
+ Sage example in ./programmation.tex, line 2393::
309
+
310
+ sage: L = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
311
+ sage: L[3:len(L)-5] == L[3-len(L):-5]
312
+ True
313
+ sage: [5 in L, 6 in L]
314
+ [True, False]
315
+
316
+ Sage example in ./programmation.tex, line 2417::
317
+
318
+ sage: L = [1, 2, 3] ; L + [10, 20, 30]
319
+ [1, 2, 3, 10, 20, 30]
320
+ sage: 4 * [1, 2, 3]
321
+ [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
322
+
323
+ Sage example in ./programmation.tex, line 2441::
324
+
325
+ sage: L = 5*[10, 20, 30] ; L[:3]+L[3:] == L
326
+ True
327
+
328
+ Sage example in ./programmation.tex, line 2459::
329
+
330
+ sage: [1..3, 7, 10..13]
331
+ [1, 2, 3, 7, 10, 11, 12, 13]
332
+
333
+ Sage example in ./programmation.tex, line 2485::
334
+
335
+ sage: list(map (cos, [0, pi/6, pi/4, pi/3, pi/2]))
336
+ [1, 1/2*sqrt(3), 1/2*sqrt(2), 1/2, 0]
337
+
338
+ Sage example in ./programmation.tex, line 2496::
339
+
340
+ sage: list(map (lambda t: cos(t), [0, pi/6, pi/4, pi/3, pi/2]))
341
+ [1, 1/2*sqrt(3), 1/2*sqrt(2), 1/2, 0]
342
+
343
+ Sage example in ./programmation.tex, line 2534::
344
+
345
+ sage: list(map (lambda t: N(cos(t)), [0, pi/6, pi/4, pi/3, pi/2]))
346
+ [1.00000000000000, 0.866025403784439, 0.707106781186548,
347
+ 0.500000000000000, 0.000000000000000]
348
+
349
+ Sage example in ./programmation.tex, line 2546::
350
+
351
+ sage: list(map (N, map (cos, [0, pi/6, pi/4, pi/3, pi/2])))
352
+ [1.00000000000000, 0.866025403784439, 0.707106781186548,
353
+ 0.500000000000000, 0.000000000000000]
354
+
355
+ Sage example in ./programmation.tex, line 2551::
356
+
357
+ sage: list(map (compose(N, cos), [0, pi/6, pi/4, pi/3, pi/2]))
358
+ [1.00000000000000, 0.866025403784439, 0.707106781186548,
359
+ 0.500000000000000, 0.000000000000000]
360
+
361
+ Sage example in ./programmation.tex, line 2564::
362
+
363
+ sage: list(filter (is_prime, [1..55]))
364
+ [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
365
+
366
+ Sage example in ./programmation.tex, line 2578::
367
+
368
+ sage: p = 37 ; list(filter (lambda n: n^4 % p == 7, [0..p-1]))
369
+ [3, 18, 19, 34]
370
+
371
+ Sage example in ./programmation.tex, line 2595::
372
+
373
+ sage: list(map(lambda n:2*n+1, [0..15]))
374
+ [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]
375
+ sage: [2*n+1 for n in [0..15]]
376
+ [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]
377
+
378
+ Sage example in ./programmation.tex, line 2607::
379
+
380
+ sage: list(filter (is_prime, [1..55]))
381
+ [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
382
+ sage: [p for p in [1..55] if is_prime(p)]
383
+ [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
384
+
385
+ Sage example in ./programmation.tex, line 2621::
386
+
387
+ sage: list(filter (is_prime, [4*n+1 for n in [0..20]]))
388
+ [5, 13, 17, 29, 37, 41, 53, 61, 73]
389
+ sage: [n^2 for n in [1..20] if is_prime(n)]
390
+ [4, 9, 25, 49, 121, 169, 289, 361]
391
+
392
+ Sage example in ./programmation.tex, line 2651::
393
+
394
+ sage: reduce (lambda x, y: 10*x+y, [1, 2, 3, 4])
395
+ 1234
396
+
397
+ Sage example in ./programmation.tex, line 2657::
398
+
399
+ sage: reduce (lambda x, y: 10*x+y, [9, 8, 7, 6], 1)
400
+ 19876
401
+
402
+ Sage example in ./programmation.tex, line 2667::
403
+
404
+ sage: L = [2*n+1 for n in [0..9]]
405
+ sage: reduce (lambda x, y: x*y, L, 1)
406
+ 654729075
407
+
408
+ Sage example in ./programmation.tex, line 2743::
409
+
410
+ sage: prod ([2*n+1 for n in [0..9]], 1) # a list with for
411
+ 654729075
412
+ sage: prod ( 2*n+1 for n in [0..9]) # without a list
413
+ 654729075
414
+ sage: prod (n for n in [0..19] if n%2 == 1)
415
+ 654729075
416
+
417
+ Sage example in ./programmation.tex, line 2764::
418
+
419
+ sage: def fct (x): return 4/x == 2
420
+ sage: all (fct(x) for x in [2, 1, 0])
421
+ False
422
+ sage: any (fct(x) for x in [2, 1, 0])
423
+ True
424
+
425
+ Sage example in ./programmation.tex, line 2793::
426
+
427
+ sage: [[x, y] for x in [1..2] for y in [6..8]]
428
+ [[1, 6], [1, 7], [1, 8], [2, 6], [2, 7], [2, 8]]
429
+
430
+ Sage example in ./programmation.tex, line 2800::
431
+
432
+ sage: [[[x, y] for x in [1..2]] for y in [6..8]]
433
+ [[[1, 6], [2, 6]], [[1, 7], [2, 7]], [[1, 8], [2, 8]]]
434
+
435
+ Sage example in ./programmation.tex, line 2810::
436
+
437
+ sage: list(map (lambda x, y: [x, y], [1..3], [6..8]))
438
+ [[1, 6], [2, 7], [3, 8]]
439
+
440
+ Sage example in ./programmation.tex, line 2829::
441
+
442
+ sage: L = [[1, 2, [3]], [4, [5, 6]], [7, [8, [9]]]]
443
+ sage: flatten (L, max_level = 1)
444
+ [1, 2, [3], 4, [5, 6], 7, [8, [9]]]
445
+ sage: flatten (L, max_level = 2)
446
+ [1, 2, 3, 4, 5, 6, 7, 8, [9]]
447
+ sage: flatten (L) # equivalent to flatten (L, max_level = 3)
448
+ [1, 2, 3, 4, 5, 6, 7, 8, 9]
449
+
450
+ Sage example in ./programmation.tex, line 2852::
451
+
452
+ sage: x = var('x')
453
+ sage: factor(diff(x*exp(x), [x, x]))
454
+ (x + 2)*e^x
455
+ sage: list(map(lambda n: factor(diff(x*exp(x), n*[x])), [0..6]))
456
+ [x*e^x, (x + 1)*e^x, (x + 2)*e^x, (x + 3)*e^x, (x + 4)*e^x,
457
+ (x + 5)*e^x, (x + 6)*e^x]
458
+ sage: [factor (diff (x*exp(x), n*[x])) for n in [0..6]]
459
+ [x*e^x, (x + 1)*e^x, (x + 2)*e^x, (x + 3)*e^x, (x + 4)*e^x,
460
+ (x + 5)*e^x, (x + 6)*e^x]
461
+
462
+ Sage example in ./programmation.tex, line 2907::
463
+
464
+ sage: L = [1, 8, 5, 2, 9] ; L.reverse() ; L
465
+ [9, 2, 5, 8, 1]
466
+ sage: L.sort() ; L
467
+ [1, 2, 5, 8, 9]
468
+ sage: L.sort(reverse = True) ; L
469
+ [9, 8, 5, 2, 1]
470
+
471
+ Sage example in ./programmation.tex, line 3031::
472
+
473
+ sage: def homogLex (P, Q):
474
+ ....: sp = sum (P) ; sq = sum (Q)
475
+ ....: if sp < sq: return int(-1)
476
+ ....: elif sp > sq: return int(1)
477
+ ....: else: return alpha (P, Q)
478
+
479
+ Sage example in ./programmation.tex, line 3038::
480
+
481
+ sage: homogLex ([2, 3, 4, 6, 4], [2, 3, 4, 5, 6])
482
+ -1
483
+
484
+ Sage example in ./programmation.tex, line 3121::
485
+
486
+ sage: def fct1(L):
487
+ ....: return [list(filter(lambda n: n % 2 == 0, L)),
488
+ ....: list(filter(lambda n: n % 2 == 1, L))]
489
+
490
+ Sage example in ./programmation.tex, line 3126::
491
+
492
+ sage: fct1([1..10])
493
+ [[2, 4, 6, 8, 10], [1, 3, 5, 7, 9]]
494
+
495
+ Sage example in ./programmation.tex, line 3145::
496
+
497
+ sage: def fct2 (L):
498
+ ....: res0 = [] ; res1 = []
499
+ ....: for k in L:
500
+ ....: if k%2 == 0: res0.append(k) # or res0[len(res0):] = [k]
501
+ ....: else: res1.append(k) # or res1[len(res1):] = [k]
502
+ ....: return [res0, res1]
503
+
504
+ Sage example in ./programmation.tex, line 3157::
505
+
506
+ sage: def fct3a (L, res0, res1):
507
+ ....: if L == []: return [res0, res1]
508
+ ....: elif L[0]%2 == 0: return fct3a(L[1:], res0+[L[0]], res1)
509
+ ....: else: return fct3a (L[1:], res0, res1+[L[0]])
510
+
511
+ Sage example in ./programmation.tex, line 3163::
512
+
513
+ sage: def fct3 (L): return fct3a (L, [], [])
514
+
515
+ Sage example in ./programmation.tex, line 3195::
516
+
517
+ sage: def subSequences (L):
518
+ ....: if L == []: return []
519
+ ....: res = [] ; start = 0 ; k = 1
520
+ ....: while k < len(L): # 2 consecutive terms are defined
521
+ ....: if L[k-1] > L[k]:
522
+ ....: res.append (L[start:k]) ; start = k
523
+ ....: k = k+1
524
+ ....: res.append (L[start:k])
525
+ ....: return res
526
+
527
+ Sage example in ./programmation.tex, line 3212::
528
+
529
+ sage: subSequences([1, 4, 1, 5])
530
+ [[1, 4], [1, 5]]
531
+ sage: subSequences([4, 1, 5, 1])
532
+ [[4], [1, 5], [1]]
533
+
534
+ Sage example in ./programmation.tex, line 3255::
535
+
536
+ sage: S = 'This is a character string.'
537
+
538
+ Sage example in ./programmation.tex, line 3277::
539
+
540
+ sage: S = 'This is a déjà-vu example.'
541
+ sage: print(S)
542
+ This is a déjà-vu example.
543
+
544
+ Sage example in ./programmation.tex, line 3322::
545
+
546
+ sage: S='one two three four five six seven'; L=S.split(); L
547
+ ['one', 'two', 'three', 'four', 'five', 'six', 'seven']
548
+
549
+ Sage example in ./programmation.tex, line 3368::
550
+
551
+ sage: L1 = [11, 22, 33] ; L2 = L1
552
+ sage: L1[1] = 222 ; L2.sort() ; L1, L2
553
+ ([11, 33, 222], [11, 33, 222])
554
+ sage: L1[2:3] = []; L2[0:0] = [6, 7, 8]
555
+ sage: L1, L2
556
+ ([6, 7, 8, 11, 33], [6, 7, 8, 11, 33])
557
+
558
+ Sage example in ./programmation.tex, line 3422::
559
+
560
+ sage: L1 = [11, 22, 33] ; L2 = L1 ; L3 = L1[:]
561
+ sage: [L1 is L2, L2 is L1, L1 is L3, L1 == L3]
562
+ [True, True, False, True]
563
+
564
+ Sage example in ./programmation.tex, line 3439::
565
+
566
+ sage: La = [1, 2, 3] ; L1 = [1, La] ; L2 = copy(L1)
567
+ sage: L1[1][0] = 5 # [1, [5, 2, 3]] for L1 and L2
568
+ sage: [L1 == L2, L1 is L2, L1[1] is L2[1]]
569
+ [True, False, True]
570
+
571
+ Sage example in ./programmation.tex, line 3498::
572
+
573
+ sage: def lexInverse (P, Q):
574
+ ....: P1 = copy(P) ; P1.reverse()
575
+ ....: Q1 = copy(Q) ; Q1.reverse()
576
+ ....: return - alpha (P1, Q1)
577
+
578
+ Sage example in ./programmation.tex, line 3593::
579
+
580
+ sage: S0 = (); S1 = (1, ); S2 = (1, 2)
581
+ sage: [1 in S1, 1 == (1)]
582
+ [True, True]
583
+
584
+ Sage example in ./programmation.tex, line 3610::
585
+
586
+ sage: S1 = (1, 4, 9, 16, 25); [k for k in S1]
587
+ [1, 4, 9, 16, 25]
588
+
589
+ Sage example in ./programmation.tex, line 3627::
590
+
591
+ sage: L1 = [0..4]; L2 = [5..9]
592
+ sage: list(zip(L1, L2))
593
+ [(0, 5), (1, 6), (2, 7), (3, 8), (4, 9)]
594
+ sage: list(map(lambda x, y:(x, y), L1, L2))
595
+ [(0, 5), (1, 6), (2, 7), (3, 8), (4, 9)]
596
+
597
+ Sage example in ./programmation.tex, line 3656::
598
+
599
+ sage: E = Set([1, 2, 4, 8, 2, 2, 2]); F = Set([7, 5, 3, 1]); E, F
600
+ ({8, 1, 2, 4}, {1, 3, 5, 7})
601
+
602
+ Sage example in ./programmation.tex, line 3678::
603
+
604
+ sage: E = Set([1, 2, 4, 8, 2, 2, 2]); F = Set([7, 5, 3, 1])
605
+ sage: 5 in E, 5 in F, E + F == F | E
606
+ (False, True, True)
607
+ sage: E & F, E - F, E ^^ F
608
+ ({1}, {8, 2, 4}, {2, 3, 4, 5, 7, 8})
609
+
610
+ Sage example in ./programmation.tex, line 3700::
611
+
612
+ sage: E = Set([1, 2, 4, 8, 2, 2, 2])
613
+ sage: [E[k] for k in [0..len(E)-1]], [t for t in E]
614
+ ([8, 1, 2, 4], [8, 1, 2, 4])
615
+
616
+ Sage example in ./programmation.tex, line 3713::
617
+
618
+ sage: def included (E, F): return E+F == F
619
+
620
+ Sage example in ./programmation.tex, line 3728::
621
+
622
+ sage: sorted(Set([Set([]), Set([1]), Set([2]), Set([1, 2])]), key=str)
623
+ [{1, 2}, {1}, {2}, {}]
624
+ sage: sorted(Set([ (), (1, ), (2, ), (1, 2) ]))
625
+ [(), (1,), (1, 2), (2,)]
626
+
627
+ Sage example in ./programmation.tex, line 3744::
628
+
629
+ sage: def Parts (EE):
630
+ ....: if EE == Set([]): return Set([EE])
631
+ ....: else:
632
+ ....: return withOrWithout (EE[0], Parts(Set(EE[1:])))
633
+
634
+ Sage example in ./programmation.tex, line 3754::
635
+
636
+ sage: def withOrWithout (a, E):
637
+ ....: return Set (map (lambda F: Set([a])+F, E)) + E
638
+
639
+ Sage example in ./programmation.tex, line 3762::
640
+
641
+ sage: sorted(Parts(Set([1, 2, 3])), key=str)
642
+ [{1, 2, 3}, {1, 2}, {1, 3}, {1}, {2, 3}, {2}, {3}, {}]
643
+
644
+ Sage example in ./programmation.tex, line 3804::
645
+
646
+ sage: D={}; D['one']=1; D['two']=2; D['three']=3; D['ten']=10
647
+ sage: D['two'] + D['three']
648
+ 5
649
+
650
+ Sage example in ./programmation.tex, line 3857::
651
+
652
+ sage: D = {'a0':'b0', 'a1':'b1', 'a2':'b2', 'a3':'b0',\
653
+ ....: 'a4':'b3', 'a5':'b3'}
654
+ sage: E = Set(D.keys()) ; Imf = Set(D.values())
655
+ sage: Imf == Set(map (lambda t:D[t], E)) # is equivalent
656
+ True
657
+
658
+ Sage example in ./programmation.tex, line 3894::
659
+
660
+ sage: def injective(D):
661
+ ....: return len(D) == len (Set(D.values()))
662
+ """