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