« Formules: Fonctions non-numériques » : différence entre les versions

De MoodleDocs
Aller à :navigation, rechercher
(Suppression double redirection)
 
(4 versions intermédiaires par un autre utilisateur non affichées)
Ligne 1 : Ligne 1 :
{{Question de type Formules}}
#REDIRECT [[Types_de_questions_tiers]]
{{Traduction}}
 
==Fonctions non numériques==
{| class="nicetable"
|-
! Fonction
! Exemples
! Resultat
! Description
|-
| rowspan="2" | concat(X1,X2, ...)
| concat([1],[2,3],[4])
| [1,2,3,4]
| rowspan="2" | Returns a list by concatenating X1, X2, ...
|-
| concat(["A"],["B"])
| ["A","B"]
|-
| rowspan="3" | diff(X,Y)<br>diff(X,Y,N)
| diff([1,1,1],[1,4,9])
| [0,3,8]
| rowspan="3" | Return a list of number D of difference between the list X and Y element wise.<br>If X and Y are a list of number, then D[i] will be abs(X[i]-Y[i]).<br>If X and Y are a list of string, then D[i] will be the difference between the algebraic formula X[i] and Y[i].
|-
| diff(["x*x"],["x^2"])
| [0]
|-
| diff(["x"],["x^2"],20)
| A list with number >= 0
|-
| fill(N,value)
| fill(3,0)
| [0,0,0]
| Returns a list with size N and all elements filled by value.
|-
| inv(X)
| inv([0,3,1,2])
| [0,2,3,1]
| Return the inverse permutation of X, which is the same as R in for(i:[0:N]) R[X[i]]=i with size N of X.<br> It has the property that X==inv(inv(X)) and A==sublist(sublist(A,X),inv(X)).
|-
| rowspan="2" | join(s,A,B...)
| join(" ",["Hello","world"])
| "Hello world"
| rowspan="2" | Returns a string that joins all elements together and separated by string s . The A, B, ... can be any number or string or list.
|-
| join("",1,"+",2,["="])
| "1+2="
|-
| len(X)
| len([0:10])
| 10
| Returns the length of the list X
|-
| rowspan="3" | map(uop,X)<br>map(bop,X,Y)
| map("abs",[-1,2,-3])
| [1,2,3]
| rowspan="3" | Returns a list by applying the operator/function element wise to all elements in X.<br>
The uop or bop are the string of unary or binary operators (or functions) for numbers respectively.<br>
map(uop,X) has the meaning as R in for(i:[0:N]) R[i]=op(X[i]);<br>
map(bop,X,Y) has the meaning as R in for(i:[0:N]) R[i]=op(X[i],Y[i]); for function or for(i:[0:N]) R[i]=X[i] bop Y[i] for operator.<br>
Either X or Y can be a number and it will automatically convert to the same size of the other list.
|-
| map("+",[1,2,3],5)
| [6,7,8]
|-
| map("<",[3,4],[1,7])
| [0,1]
|-
| rowspan="3" | pick(i,X)<br>pick(i,x0,x1,...)
| pick(1<2,["A","B"])
| "B"
| rowspan="3" | A safe variant of list subscript. It picks the i-th element from the list X or the first element if index out of range.<br>pick(i,x0,x1,...) picks the i-th element in the [x0,x1,...] , or x0 if index out of range.
|-
| pick(10,"","A","B")
| ""
|-
| pick(1,[1,2],[3,4])
| [3,4]
|-
| rowspan="2" | sort(X)<br>sort(X,Y)
| sort(["B","C","A"])
| ["A","B","C"]
| rowspan="2" | Returns the sorted list of X in ascending order.<br>
sort(X,Y) sortd the list X,Y together by sorting Y in ascending order and returns the sorted list X.
|-
| sort(["B","C","A"],[0,2,1])
| ["B","A","C"]
|-
| str(x)
| str(1.1)
| "1.1"
| Converts the number x into a string
|-
| rowspan="2" | sublist(X,Y)
| sublist([7,8,9],[1,1,2])
| [8,8,9]
| rowspan="2" | Returns a sublist R of X using list Y as index, where R[i] = X[Y[i]].<br>If Y is a permutation, say Y=shuffle([0:5]), then X is permuted depending on Y sum(X).
|-
| sublist([7,8,9],[2,1,0])
| [9,8,7]
|-
| sum(X)
| sum([1,2,3])
| 6
| Returns the sum of all elements in the list of numbers X
|-
|}
 
 
 
[[#top|Accéder au haut de la page]]
 
[[Question de type Formules|← QUESTION DE TYPE FORMULES]]
 
===Autres langues===
[https://docs.moodle.org/33/en/Formulas:_Non-numerical_functions English]<br>
[https://docs.moodle.org/all/es/Tipo_de_pregunta_f%C3%B3rmulas Español]

Dernière version du 17 mai 2019 à 14:58

Rediriger vers :