In computer science, the Schwartzian Transform is a Perl programming idiom used to improve the efficiency of sorting a list of items. This idiom is appropriate for comparison-based sorting when comparing a pair of elements is a compute-intensive operation that should be performed a minimal number of times. The Schwartzian Transform is notable in that it does not use named temporary arrays. The idiom is named after Randal L.
| Property | Value |
| dbpprop:abstract
|
- In computer science, the Schwartzian Transform is a Perl programming idiom used to improve the efficiency of sorting a list of items. This idiom is appropriate for comparison-based sorting when comparing a pair of elements is a compute-intensive operation that should be performed a minimal number of times. The Schwartzian Transform is notable in that it does not use named temporary arrays. The idiom is named after Randal L. Schwartz, who first demonstrated it in Perl shortly after the release of Perl 5 in 1994. The term "Schwartzian Transform" applied solely to Perl programming for a number of years, but it has later been adopted by some users of other languages, such as Python, to refer to similar idioms in those languages. However, the algorithm was already in use in other languages (under no specific name) before it was popularized among the Perl community in the form of that particular idiom by Schwartz. The term "Schwartzian transform" indicates a specific idiom, and not the algorithm in general. The Schwartzian Transform is a version of a Lisp idiom known as decorate-sort-undecorate, which avoids recomputing the sort keys by temporarily associating them with the input items. This approach is similar to memoization, which avoids repeating the calculation of the key corresponding to a specific input value. By comparison, this idiom assures that each input item's key is calculated exactly once, which may still result in repeating some calculations if the input data contains duplicate items. And in the 1960s sort generators "own coding" features facilitated similar input/output transformations for ease of comparing records (among other things).
- La transformada schwartziana és una tècnica en programació que s'utilitza per a l'ordenació eficient d'una matriu. Aquesta fa servir el resultat d'una operació de càlcul intensiu sense la necessitat d'efectuar-la per a cada comparació que fa la subrutina de comparació. Aquesta pràctica rep el nom de Randal L. Schwartz, qui va popularitzar-la entre els programadors de Perl. No obstant això, s'ha utilitzat en informàtica com a mínim des de l'estàndard Common Lisp. És un cas especial de memoització, que funcionaria per a qualsevol algorisme. Per exemple, per a ordernar una llista de fitxers d'acord amb el seu moment de modificació, sense transformada seria: funció ComparacióIngènua(fitxer a, fitxer b) { retorna TempsModificació(a) < TempsModificació(b) // S'assumeix que ordena(llista, PredicatComparació) ordena la llista fent servir // el PredicatComparació per a comparar dos elements. MatriuOrdenada := ordena(MatriuFitxers, ComparacióIngènua) A menys que els temps de modificació es memoitzin per a cada fitxer, aquest mètode requereix tornar a calcular cada vegada que un fitxer es compara en l'ordenació. Com a alternativa, amb la transformada schwartziana: per cada fitxer a MatriuFitxers inserta Matrix(fitxer, TempsModificació) al final de MatriuTransformada funció ComparacióSimple(matriu a, matriu b) { retorna a[2] < b[2] MatriuTransformada := ordena(MatriuTransformada, ComparacióSimple) per cada fitxer a MatriuTransformada inserta MatriuTransformada[1] al final MatriuOrdenada Primer el bucle inicial itera cada element de MatriuFitxers i crea una referència d'una matriu anònima per a cada un. La matriu anònima té doncs dos elements: l'original de MatriuFitxers i el temps de modificació d'aqueix fitxer. A continuació s'ordena la llista de referències de matrius anònimes que retorna el primer mapatge. La llista s'ordena d'acord amb els segons elements de cada matriu anònima. Finalment la llista ordenada de referències de matrius s'itera en el darrer bucle. Aquest simplement construeix la matriu ordenada a partir del primer element de cada referència de les matrius, que és de fet el nom del fitxer.
|
| dbpprop:hasPhotoCollection
| |
| dbpprop:reference
| |
| dbpprop:wikiPageUsesTemplate
| |
| dbpprop:wikibooksProperty
|
- Algorithm implementation
- Schwartzian transform
- Sorting/Schwartzian transform
|
| rdf:type
| |
| rdfs:comment
|
- In computer science, the Schwartzian Transform is a Perl programming idiom used to improve the efficiency of sorting a list of items. This idiom is appropriate for comparison-based sorting when comparing a pair of elements is a compute-intensive operation that should be performed a minimal number of times. The Schwartzian Transform is notable in that it does not use named temporary arrays. The idiom is named after Randal L.
- La transformada schwartziana és una tècnica en programació que s'utilitza per a l'ordenació eficient d'una matriu. Aquesta fa servir el resultat d'una operació de càlcul intensiu sense la necessitat d'efectuar-la per a cada comparació que fa la subrutina de comparació. Aquesta pràctica rep el nom de Randal L. Schwartz, qui va popularitzar-la entre els programadors de Perl. No obstant això, s'ha utilitzat en informàtica com a mínim des de l'estàndard Common Lisp.
|
| rdfs:label
|
- Schwartzian transform
- Transformada schwartziana
|
| owl:sameAs
| |
| skos:subject
| |
| foaf:page
| |
| is dbpedia-owl:Person/knownFor
of | |
| is dbpedia-owl:knownFor
of | |
| is dbpprop:knownFor
of | |
| is dbpprop:redirect
of | |
| is owl:sameAs
of | |