mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-01-17 13:38:38 +01:00
Merge branch 'master' of github.com:adambard/learnxinyminutes-docs
Pulling from master to work on Java[en] inputs
This commit is contained in:
commit
13663f3726
@ -92,8 +92,8 @@ case, or ceiling of growth for a given function. It provides us with an
|
||||
_**asymptotic upper bound**_ for the growth rate of runtime of an algorithm.
|
||||
Say `f(n)` is your algorithm runtime, and `g(n)` is an arbitrary time
|
||||
complexity you are trying to relate to your algorithm. `f(n)` is O(g(n)), if
|
||||
for some real constant c (c > 0), `f(n)` <= `c g(n)` for every input size
|
||||
n (n > 0).
|
||||
for some real constants c (c > 0) and n<sub>0</sub>, `f(n)` <= `c g(n)` for every input size
|
||||
n (n > n<sub>0</sub>).
|
||||
|
||||
*Example 1*
|
||||
|
||||
@ -110,7 +110,7 @@ Let's look to the definition of Big-O.
|
||||
3log n + 100 <= c * log n
|
||||
```
|
||||
|
||||
Is there some constant c that satisfies this for all n?
|
||||
Is there some pair of constants c, n<sub>0</sub> that satisfies this for all n > <sub>0</sub>?
|
||||
|
||||
```
|
||||
3log n + 100 <= 150 * log n, n > 2 (undefined at n = 1)
|
||||
@ -133,7 +133,7 @@ Let's look at the definition of Big-O.
|
||||
3 * n^2 <= c * n
|
||||
```
|
||||
|
||||
Is there some constant c that satisfies this for all n?
|
||||
Is there some pair of constants c, n<sub>0</sub> that satisfies this for all n > <sub>0</sub>?
|
||||
No, there isn't. `f(n)` is NOT O(g(n)).
|
||||
|
||||
### Big-Omega
|
||||
@ -141,8 +141,8 @@ Big-Omega, commonly written as **Ω**, is an Asymptotic Notation for the best
|
||||
case, or a floor growth rate for a given function. It provides us with an
|
||||
_**asymptotic lower bound**_ for the growth rate of runtime of an algorithm.
|
||||
|
||||
`f(n)` is Ω(g(n)), if for some real constant c (c > 0), `f(n)` is >= `c g(n)`
|
||||
for every input size n (n > 0).
|
||||
`f(n)` is Ω(g(n)), if for some real constants c (c > 0) and n<sub>0</sub> (n<sub>0</sub> > 0), `f(n)` is >= `c g(n)`
|
||||
for every input size n (n > n<sub>0</sub>).
|
||||
|
||||
### Note
|
||||
|
||||
@ -155,8 +155,8 @@ Small-o, commonly written as **o**, is an Asymptotic Notation to denote the
|
||||
upper bound (that is not asymptotically tight) on the growth rate of runtime
|
||||
of an algorithm.
|
||||
|
||||
`f(n)` is o(g(n)), if for any real constant c (c > 0), `f(n)` is < `c g(n)`
|
||||
for every input size n (n > 0).
|
||||
`f(n)` is o(g(n)), if for some real constants c (c > 0) and n<sub>0</sub> (n<sub>0</sub> > 0), `f(n)` is < `c g(n)`
|
||||
for every input size n (n > n<sub>0</sub>).
|
||||
|
||||
The definitions of O-notation and o-notation are similar. The main difference
|
||||
is that in f(n) = O(g(n)), the bound f(n) <= g(n) holds for _**some**_
|
||||
@ -168,8 +168,8 @@ Small-omega, commonly written as **ω**, is an Asymptotic Notation to denote
|
||||
the lower bound (that is not asymptotically tight) on the growth rate of
|
||||
runtime of an algorithm.
|
||||
|
||||
`f(n)` is ω(g(n)), if for any real constant c (c > 0), `f(n)` is > `c g(n)`
|
||||
for every input size n (n > 0).
|
||||
`f(n)` is ω(g(n)), if for some real constants c (c > 0) and n<sub>0</sub> (n<sub>0</sub> > 0), `f(n)` is > `c g(n)`
|
||||
for every input size n (n > n<sub>0</sub>).
|
||||
|
||||
The definitions of Ω-notation and ω-notation are similar. The main difference
|
||||
is that in f(n) = Ω(g(n)), the bound f(n) >= g(n) holds for _**some**_
|
||||
@ -180,8 +180,8 @@ _**all**_ constants c > 0.
|
||||
Theta, commonly written as **Θ**, is an Asymptotic Notation to denote the
|
||||
_**asymptotically tight bound**_ on the growth rate of runtime of an algorithm.
|
||||
|
||||
`f(n)` is Θ(g(n)), if for some real constants c1, c2 (c1 > 0, c2 > 0),
|
||||
`c1 g(n)` is < `f(n)` is < `c2 g(n)` for every input size n (n > 0).
|
||||
`f(n)` is Θ(g(n)), if for some real constants c1, c2 and n<sub>0</sub> (c1 > 0, c2 > 0, n<sub>0</sub> > 0),
|
||||
`c1 g(n)` is < `f(n)` is < `c2 g(n)` for every input size n (n > n<sub>0</sub>).
|
||||
|
||||
∴ `f(n)` is Θ(g(n)) implies `f(n)` is O(g(n)) as well as `f(n)` is Ω(g(n)).
|
||||
|
||||
|
@ -1006,15 +1006,101 @@ on a new line! ""Wow!"", the masses cried";
|
||||
// x?.y will return null immediately if x is null; y is not evaluated
|
||||
=> GenieName?.ToUpper();
|
||||
}
|
||||
|
||||
static class MagicService
|
||||
{
|
||||
private static bool LogException(Exception ex)
|
||||
{
|
||||
/* log exception somewhere */
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CastSpell(string spell)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Pretend we call API here
|
||||
throw new MagicServiceException("Spell failed", 42);
|
||||
|
||||
// Spell succeeded
|
||||
return true;
|
||||
}
|
||||
// Only catch if Code is 42 i.e. spell failed
|
||||
catch(MagicServiceException ex) when (ex.Code == 42)
|
||||
{
|
||||
// Spell failed
|
||||
return false;
|
||||
}
|
||||
// Other exceptions, or MagicServiceException where Code is not 42
|
||||
catch(Exception ex) when (LogException(ex))
|
||||
{
|
||||
// Execution never reaches this block
|
||||
// The stack is not unwound
|
||||
}
|
||||
return false;
|
||||
// Note that catching a MagicServiceException and rethrowing if Code
|
||||
// is not 42 or 117 is different, as then the final catch-all block
|
||||
// will not catch the rethrown exception
|
||||
}
|
||||
}
|
||||
|
||||
public class MagicServiceException : Exception
|
||||
{
|
||||
public int Code { get; }
|
||||
|
||||
public MagicServiceException(string message, int code) : base(message)
|
||||
{
|
||||
Code = code;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PragmaWarning {
|
||||
// Obsolete attribute
|
||||
[Obsolete("Use NewMethod instead", false)]
|
||||
public static void ObsoleteMethod()
|
||||
{
|
||||
/* obsolete code */
|
||||
}
|
||||
|
||||
public static void NewMethod()
|
||||
{
|
||||
/* new code */
|
||||
}
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
ObsoleteMethod(); // CS0618: 'ObsoleteMethod is obsolete: Use NewMethod instead'
|
||||
#pragma warning disable CS0618
|
||||
ObsoleteMethod(); // no warning
|
||||
#pragma warning restore CS0618
|
||||
ObsoleteMethod(); // CS0618: 'ObsoleteMethod is obsolete: Use NewMethod instead'
|
||||
}
|
||||
}
|
||||
} // End Namespace
|
||||
|
||||
using System;
|
||||
// C# 6, static using
|
||||
using static System.Math;
|
||||
|
||||
namespace Learning.More.CSharp
|
||||
{
|
||||
class StaticUsing
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
// Without a static using statement..
|
||||
Console.WriteLine("The square root of 4 is {}.", Math.Sqrt(4));
|
||||
// With one
|
||||
Console.WriteLine("The square root of 4 is {}.", Sqrt(4));
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Topics Not Covered
|
||||
|
||||
* Attributes
|
||||
* async/await, pragma directives
|
||||
* Exception filters
|
||||
* `using static`
|
||||
* async/await
|
||||
* Web Development
|
||||
* ASP.NET MVC & WebApi (new)
|
||||
* ASP.NET Web Forms (old)
|
||||
|
@ -10,7 +10,7 @@ lang: de-de
|
||||
|
||||
YAML ist eine Sprache zur Datenserialisierung, die sofort von Menschenhand geschrieben und gelesen werden kann.
|
||||
|
||||
YAML ist eine Erweiterung von JSON, mit der Erweiterung von syntaktisch wichtigen Zeilenumbrüche und Einrückung sowie in Python. Anders als in Python erlaubt YAML keine Tabulator-Zeichen.
|
||||
YAML ist ein Erweiterung von von JSON mit der Erweiterung um syntaktisch wichtige Zeilenumbrüche und Einrückungen, ähnlich wie auch in Python. Anders als in Python allerdings erlaubt YAML keine Tabulator-Zeichen.
|
||||
|
||||
```yaml
|
||||
# Kommentare in YAML schauen so aus.
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
language: elisp
|
||||
contributors:
|
||||
- ["Bastien Guerry", "http://bzg.fr"]
|
||||
- ["Bastien Guerry", "https://bzg.fr"]
|
||||
- ["Saurabh Sandav", "http://github.com/SaurabhSandav"]
|
||||
filename: learn-emacs-lisp.el
|
||||
---
|
||||
@ -9,7 +9,7 @@ filename: learn-emacs-lisp.el
|
||||
```scheme
|
||||
;; This gives an introduction to Emacs Lisp in 15 minutes (v0.2d)
|
||||
;;
|
||||
;; Author: Bastien / @bzg2 / http://bzg.fr
|
||||
;; Author: Bastien / @bzg2 / https://bzg.fr
|
||||
;;
|
||||
;; First make sure you read this text by Peter Norvig:
|
||||
;; http://norvig.com/21-days.html
|
||||
@ -225,6 +225,8 @@ filename: learn-emacs-lisp.el
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Let's store a list of names:
|
||||
;; If you want to create a literal list of data, use ' to stop it from
|
||||
;; being evaluated - literally, "quote" the data.
|
||||
(setq list-of-names '("Sarah" "Chloe" "Mathilde"))
|
||||
|
||||
;; Get the first element of this list with `car':
|
||||
|
372
fr-fr/elisp-fr.html.markdown
Normal file
372
fr-fr/elisp-fr.html.markdown
Normal file
@ -0,0 +1,372 @@
|
||||
---
|
||||
language: elisp
|
||||
contributors:
|
||||
- ["Bastien Guerry", "https://bzg.fr"]
|
||||
- ["Saurabh Sandav", "http://github.com/SaurabhSandav"]
|
||||
translators:
|
||||
- ["Bastien Guerry", "https://bzg.fr"]
|
||||
filename: learn-emacs-lisp-fr.el
|
||||
lang: fr-fr
|
||||
---
|
||||
|
||||
```scheme
|
||||
;; Ceci est une introduction à Emacs Lisp en 15 minutes (v0.2d)
|
||||
;;
|
||||
;; Auteur : Bastien / @bzg2 / https://bzg.fr
|
||||
;;
|
||||
;; Prenez d'abord le temps de lire ce texte en anglais de Peter Norvig :
|
||||
;; http://norvig.com/21-days.html
|
||||
;;
|
||||
;; Ensuite installez GNU Emacs 24.3 (ou une version ultérieure) :
|
||||
;;
|
||||
;; Debian : apt-get install emacs (voir les instructions pour votre distribution)
|
||||
;; MacOSX : http://emacsformacosx.com/emacs-builds/Emacs-24.3-universal-10.6.8.dmg
|
||||
;; Windows : http://ftp.gnu.org/gnu/windows/emacs/emacs-24.3-bin-i386.zip
|
||||
;;
|
||||
;; Vous trouverez plus d'informations sur l'installation :
|
||||
;; http://www.gnu.org/software/emacs/#Obtaining
|
||||
|
||||
;; Avertissement important :
|
||||
;;
|
||||
;; Suivre ce tutoriel ne risque pas d'endommager votre ordinateur,
|
||||
;; sauf si vous vous énervez au point de le jeter par terre. En tout
|
||||
;; cas, je décline toute responsabilité en cas de problème.
|
||||
;; Amusez-vous bien !
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Lancez Emacs.
|
||||
;;
|
||||
;; Tapez la touche "q" pour enlever le message d'accueil.
|
||||
;;
|
||||
;; Maintenant regardez la ligne grise au pied de la fenêtre :
|
||||
;;
|
||||
;; "*scratch*" est le nom de l'espace d'édition dans lequel vous vous
|
||||
;; trouvez. Cet espace d'édition est appelé un "buffer".
|
||||
;;
|
||||
;; Le buffer scratch est le buffer par défaut quand on ouvre Emacs.
|
||||
;; Vous n'éditez jamais de fichier directement : vous éditez des
|
||||
;; buffers que vous pouvez sauvegarder dans des fichiers.
|
||||
;;
|
||||
;; "Lisp interaction" désigne le jeu de commandes disponible ici.
|
||||
;;
|
||||
;; Emacs a un jeu de commandes par défaut pour chaque buffer, et
|
||||
;; plusieurs autres jeux de commandes disponibles quand vous activez
|
||||
;; un mode particulier. Ici nous utilisons `lisp-interaction-mode',
|
||||
;; qui propose des commandes pour évaluer et naviguer dans du code
|
||||
;; Elisp.
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Le point-virgule commence un commentaire partout sur une ligne.
|
||||
;;
|
||||
;; Les programmes Elisp sont composés d'expressions symboliques aussi
|
||||
;; appelées "sexps" :
|
||||
(+ 2 2)
|
||||
|
||||
;; Cette expression symbolique se lit "Ajouter 2 à 2".
|
||||
|
||||
;; Les sexps sont placées entre parenthèses, possiblement sur
|
||||
;; plusieurs niveaux :
|
||||
(+ 2 (+ 1 1))
|
||||
|
||||
;; Une expression symbolique contient des atomes ou d'autres
|
||||
;; expressions symboliques. Dans les exemples ci-dessus, 1 et 2 sont
|
||||
;; des atomes et (+ 2 (+ 1 1)) et (+ 1 1) des expressions symboliques.
|
||||
|
||||
;; Dans le mode `lisp-interaction-mode' vous pouvez évaluer les sexps.
|
||||
;; Placez le curseur juste après la parenthèse fermante, tenez la
|
||||
;; touche "Control" enfoncée et appuyez sur la touche "j" (soit le
|
||||
;; raccourci "C-j").
|
||||
|
||||
(+ 3 (+ 1 2))
|
||||
;; ^ curseur ici
|
||||
;; `C-j' => 6
|
||||
|
||||
;; `C-j' insère le résultat de l'évaluation dans le buffer.
|
||||
|
||||
;; `C-x C-e' affiche le même résultat dans la ligne tout en bas
|
||||
;; d'Emacs, appelée le "minibuffer". On utilise en général `C-x C-e',
|
||||
;; pour ne pas encombrer le buffer avec du texte inutile.
|
||||
|
||||
;; `setq' assigne une valeur à une variable :
|
||||
(setq my-name "Bastien")
|
||||
;; `C-x C-e' => "Bastien" (affiché dans le minibuffer)
|
||||
|
||||
;; `insert' va insérer "Hello!" là où se trouve le curseur :
|
||||
(insert "Hello!")
|
||||
;; `C-x C-e' => "Hello!"
|
||||
|
||||
;; Nous utilisons `insert' avec un seul argument "Hello!", mais
|
||||
;; nous pouvons passer plus d'arguments - ici nous en passons deux :
|
||||
|
||||
(insert "Hello" " world!")
|
||||
;; `C-x C-e' => "Hello world!"
|
||||
|
||||
;; Vous pouvez utiliser des variables au lieu de chaînes de caractères :
|
||||
(insert "Hello, I am " my-name)
|
||||
;; `C-x C-e' => "Hello, I am Bastien"
|
||||
|
||||
;; Vous pouvez combiner les sexps en fonctions :
|
||||
(defun hello () (insert "Hello, I am " my-name))
|
||||
;; `C-x C-e' => hello
|
||||
|
||||
;; Vous pouvez évaluer les fonctions :
|
||||
(hello)
|
||||
;; `C-x C-e' => Hello, I am Bastien
|
||||
|
||||
;; Les parenthèses vides dans la définition de la fonction signifient
|
||||
;; qu'elle ne prend pas d'argument. Mais toujours utiliser `my-name'
|
||||
;; est ennuyant, demandons à la fonction d'accepter un argument (ici
|
||||
;; l'argument est appelé "name") :
|
||||
|
||||
(defun hello (name) (insert "Hello " name))
|
||||
;; `C-x C-e' => hello
|
||||
|
||||
;; Maintenant appelons la fonction avec la chaîne de caractères "you"
|
||||
;; comme valeur de son unique argument :
|
||||
(hello "you")
|
||||
;; `C-x C-e' => "Hello you"
|
||||
|
||||
;; Youpi!
|
||||
|
||||
;; Faites une pause.
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Maintenant ouvrez un nouveau buffer appelé "*test*" dans une
|
||||
;; nouvelle fenêtre :
|
||||
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
;; `C-x C-e'
|
||||
;; => [l'écran a deux fenêtres et le curseur est dans le buffer *test*]
|
||||
|
||||
;; Placez la souris sur la fenêtre du haut et cliquez-gauche pour
|
||||
;; retourner dans cette fenêtre. Ou bien utilisez `C-x o' (i.e. tenez
|
||||
;; control-x appuyé et appuyez sur o) pour aller dans l'autre fenêtre
|
||||
;; interactivement.
|
||||
|
||||
;; Vous pouvez combiner plusieurs sexps avec `progn' :
|
||||
(progn
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
(hello "you"))
|
||||
;; `C-x C-e'
|
||||
;; => [L'écran a deux fenêtres et le curseur est dans le buffer *test*]
|
||||
|
||||
;; Maintenant si ça ne vous dérange pas, je vais arrêter de vous
|
||||
;; demander de faire `C-x C-e' : faites-le pour chaque sexp qui suit.
|
||||
|
||||
;; Retournez toujours dans le buffer *scratch* avec la souris ou `C-x o'.
|
||||
|
||||
;; Il est souvent utile d'effacer le contenu du buffer :
|
||||
(progn
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
(erase-buffer)
|
||||
(hello "there"))
|
||||
|
||||
;; Ou d'aller à l'autre fenêtre :
|
||||
(progn
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
(erase-buffer)
|
||||
(hello "you")
|
||||
(other-window 1))
|
||||
|
||||
;; Vous pouvez associer une valeur à une variable locale avec `let' :
|
||||
(let ((local-name "you"))
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
(erase-buffer)
|
||||
(hello local-name)
|
||||
(other-window 1))
|
||||
|
||||
;; Dans ce cas pas besoin d'utiliser `progn' puisque `let' combine
|
||||
;; aussi plusieurs sexps.
|
||||
|
||||
;; Mettons en forme une chaîne de caractères :
|
||||
(format "Hello %s!\n" "visitor")
|
||||
|
||||
;; %s désigne l'emplacement de la chaîne, remplacé par "visitor".
|
||||
;; \n est le caractère de saut de ligne.
|
||||
|
||||
;; Améliorons notre fonction en utilisant "format" :
|
||||
(defun hello (name)
|
||||
(insert (format "Hello %s!\n" name)))
|
||||
|
||||
(hello "you")
|
||||
|
||||
;; Créons une autre fonction qui utilise `let' :
|
||||
(defun greeting (name)
|
||||
(let ((your-name "Bastien"))
|
||||
(insert (format "Hello %s!\n\nI am %s."
|
||||
name ; l'argument de la fonction
|
||||
your-name ; la variable "let-bindée" "Bastien"
|
||||
))))
|
||||
|
||||
;; Et évaluons-la :
|
||||
(greeting "you")
|
||||
|
||||
;; Certaines fonctions sont interactives :
|
||||
(read-from-minibuffer "Enter your name: ")
|
||||
|
||||
;; Évaluer cette fonction va renvoyer ce que vous avez saisi dans le
|
||||
;; minibuffer.
|
||||
|
||||
;; Faisons que notre fonction `greeting' vous demande votre nom :
|
||||
(defun greeting (from-name)
|
||||
(let ((your-name (read-from-minibuffer "Enter your name: ")))
|
||||
(insert (format "Hello!\n\nI am %s and you are %s."
|
||||
from-name ; l'argument de la fonction
|
||||
your-name ; la variable "let-bindée", entrée dans le minibuffer
|
||||
))))
|
||||
|
||||
(greeting "Bastien")
|
||||
|
||||
;; Complétons la fonction pour qu'elle affiche le résultat dans
|
||||
;; l'autre fenêtre :
|
||||
(defun greeting (from-name)
|
||||
(let ((your-name (read-from-minibuffer "Enter your name: ")))
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
(erase-buffer)
|
||||
(insert (format "Hello %s!\n\nI am %s." your-name from-name))
|
||||
(other-window 1)))
|
||||
|
||||
;; Maintenant testons :
|
||||
(greeting "Bastien")
|
||||
|
||||
;; Faites une pause.
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Stockons une liste de noms :
|
||||
(setq list-of-names '("Sarah" "Chloe" "Mathilde"))
|
||||
|
||||
;; Récupérez le premier élément de la liste avec `car' :
|
||||
(car list-of-names)
|
||||
|
||||
;; Récupérez tous les élements sauf le premier avec `cdr' :
|
||||
(cdr list-of-names)
|
||||
|
||||
;; Ajoutez un élément au début avec `push' :
|
||||
(push "Stephanie" list-of-names)
|
||||
|
||||
;; Note : `car' et `cdr' ne modifient pas la liste, mais `push' oui.
|
||||
;; C'est une différence importante : certaines fonctions n'ont pas
|
||||
;; d'effets de bord (comme `car') et d'autres oui (comme `push').
|
||||
|
||||
;; Évaluons `hello' pour tous les éléments dans `list-of-names' :
|
||||
(mapcar 'hello list-of-names)
|
||||
|
||||
;; Améliorons `greeting' pour dire hello aux noms de `list-of-names' :
|
||||
(defun greeting ()
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
(erase-buffer)
|
||||
(mapcar 'hello list-of-names)
|
||||
(other-window 1))
|
||||
|
||||
(greeting)
|
||||
|
||||
;; Vous vous souvenez de la fonction `hello' définie ci-dessus ? Elle
|
||||
;; prend seulement un argument, un nom. `mapcar' appelle `hello' en
|
||||
;; utilisant successivement chaque élément de `list-of-names' comme
|
||||
;; argument de `hello'.
|
||||
|
||||
;; Maintenant arrangeons un peu ce qui est affiché dans le buffer :
|
||||
|
||||
(defun replace-hello-by-bonjour ()
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
(goto-char (point-min))
|
||||
(while (search-forward "Hello")
|
||||
(replace-match "Bonjour"))
|
||||
(other-window 1))
|
||||
|
||||
;; (goto-char (point-min)) va au début du buffer.
|
||||
;; (search-forward "Hello") cherche la chaîne "Hello".
|
||||
;; (while x y) évalue la sexp(s) y tant que x renvoie quelque chose.
|
||||
;; Si x renvoie `nil' (rien), nous sortons de la boucle.
|
||||
|
||||
(replace-hello-by-bonjour)
|
||||
|
||||
;; Vous devriez voir toutes les occurrences de "Hello" dans le buffer
|
||||
;; *test* remplacées par "Bonjour".
|
||||
|
||||
;; Vous devriez aussi avoir une erreur : "Search failed: Hello".
|
||||
;;
|
||||
;; Pour éviter cette erreur, il faut dire à `search-forward' si la
|
||||
;; recherche doit s'arrêter à un certain point du buffer, et si elle
|
||||
;; doit s'arrêter silencieusement si aucune chaîne n'est trouvée.
|
||||
|
||||
;; (search-forward "Hello" nil t) fait ça :
|
||||
|
||||
;; L'argument `nil' indique que la recherche n'est pas limitée à une
|
||||
;; position. L'argument `t' indique de s'arrêter silencieusement si
|
||||
;; rien n'est trouvé.
|
||||
|
||||
;; Nous utilisons cette sexp dans la fonction ci-dessous, qui ne
|
||||
;; renvoie pas d'erreur :
|
||||
|
||||
(defun hello-to-bonjour ()
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
(erase-buffer)
|
||||
;; Dit hello aux noms de `list-of-names'
|
||||
(mapcar 'hello list-of-names)
|
||||
(goto-char (point-min))
|
||||
;; Remplace "Hello" par "Bonjour"
|
||||
(while (search-forward "Hello" nil t)
|
||||
(replace-match "Bonjour"))
|
||||
(other-window 1))
|
||||
|
||||
(hello-to-bonjour)
|
||||
|
||||
;; Mettons les noms en gras :
|
||||
|
||||
(defun boldify-names ()
|
||||
(switch-to-buffer-other-window "*test*")
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "Bonjour \\(.+\\)!" nil t)
|
||||
(add-text-properties (match-beginning 1)
|
||||
(match-end 1)
|
||||
(list 'face 'bold)))
|
||||
(other-window 1))
|
||||
|
||||
;; Cette fonction introduit `re-search-forward' : au lieu de chercher
|
||||
;; la chaîne "Bonjour", nous cherchons un "pattern" en utilisant une
|
||||
;; "expression régulière" (le préfixe "re-" signifie "regular
|
||||
;; expression").
|
||||
|
||||
;; L'expression régulière est "Bonjour \\(.+\\)!" et se lit :
|
||||
;; la chaîne "Bonjour ", et
|
||||
;; un groupe de | c'est la syntaxe \\( ... \\)
|
||||
;; n'importe quel caractère | c'est le .
|
||||
;; une ou plusieurs fois | c'est le +
|
||||
;; et la chaîne "!".
|
||||
|
||||
;; Prêt ? Testons !
|
||||
|
||||
(boldify-names)
|
||||
|
||||
;; `add-text-properties' ajoute des propriétés textuelles telle que
|
||||
;; des "faces" (une "face" définit la fonte, la couleur, la taille et
|
||||
;; d'autres propriétés du texte.)
|
||||
|
||||
;; Et voilà, c'est fini. Happy hacking!
|
||||
|
||||
;; Si vous voulez en savoir plus sur une variable ou une fonction :
|
||||
;;
|
||||
;; C-h v une-variable RET
|
||||
;; C-h f une-fonction RET
|
||||
;;
|
||||
;; Pour lire le manuel Emacs Lisp avec Emacs :
|
||||
;;
|
||||
;; C-h i m elisp RET
|
||||
;;
|
||||
;; Pour lire en ligne une introduction à Emacs Lisp :
|
||||
;; https://www.gnu.org/software/emacs/manual/html_node/eintr/index.html
|
||||
|
||||
;; Merci à ces personnes pour leurs retours et suggetions :
|
||||
;; - Wes Hardaker
|
||||
;; - notbob
|
||||
;; - Kevin Montuori
|
||||
;; - Arne Babenhauserheide
|
||||
;; - Alan Schmitt
|
||||
;; - LinXitoW
|
||||
;; - Aaron Meurer
|
||||
```
|
@ -68,7 +68,7 @@ not False -- True
|
||||
----------------------------------------------------
|
||||
|
||||
-- Every element in a list must have the same type.
|
||||
-- These two lists are the same:
|
||||
-- These two lists are equal:
|
||||
[1, 2, 3, 4, 5]
|
||||
[1..5]
|
||||
|
||||
@ -77,11 +77,11 @@ not False -- True
|
||||
|
||||
-- You can create a step in a range.
|
||||
[0,2..10] -- [0, 2, 4, 6, 8, 10]
|
||||
[5..1] -- This doesn't work because Haskell defaults to incrementing.
|
||||
[5..1] -- [] (Haskell defaults to incrementing)
|
||||
[5,4..1] -- [5, 4, 3, 2, 1]
|
||||
|
||||
-- indexing into a list
|
||||
[1..10] !! 3 -- 4
|
||||
[1..10] !! 3 -- 4 (zero-based indexing)
|
||||
|
||||
-- You can also have infinite lists in Haskell!
|
||||
[1..] -- a list of all the natural numbers
|
||||
@ -152,8 +152,8 @@ fib x
|
||||
| otherwise = fib (x - 1) + fib (x - 2)
|
||||
|
||||
-- Pattern matching is similar. Here we have given three different
|
||||
-- definitions for fib. Haskell will automatically call the first
|
||||
-- function that matches the pattern of the value.
|
||||
-- equations that define fib. Haskell will automatically use the first
|
||||
-- equation whose left hand side pattern matches the value.
|
||||
fib 1 = 1
|
||||
fib 2 = 2
|
||||
fib x = fib (x - 1) + fib (x - 2)
|
||||
@ -198,11 +198,11 @@ foo 5 -- 15
|
||||
-- multiplies the result of that by 4, and then returns the final value.
|
||||
foo = (4*) . (10+)
|
||||
|
||||
-- 4*(10 + 5) = 60
|
||||
-- 4*(10+5) = 60
|
||||
foo 5 -- 60
|
||||
|
||||
-- fixing precedence
|
||||
-- Haskell has another operator called `$`. This operator applies a function
|
||||
-- Haskell has an operator called `$`. This operator applies a function
|
||||
-- to a given parameter. In contrast to standard function application, which
|
||||
-- has highest possible priority of 10 and is left-associative, the `$` operator
|
||||
-- has priority of 0 and is right-associative. Such a low priority means that
|
||||
@ -244,10 +244,10 @@ double x = x * 2
|
||||
-- 6. Control Flow and If Expressions
|
||||
----------------------------------------------------
|
||||
|
||||
-- if expressions
|
||||
-- if-expressions
|
||||
haskell = if 1 == 1 then "awesome" else "awful" -- haskell = "awesome"
|
||||
|
||||
-- if expressions can be on multiple lines too, indentation is important
|
||||
-- if-expressions can be on multiple lines too, indentation is important
|
||||
haskell = if 1 == 1
|
||||
then "awesome"
|
||||
else "awful"
|
||||
@ -295,11 +295,10 @@ data Color = Red | Blue | Green
|
||||
|
||||
-- Now you can use it in a function:
|
||||
|
||||
|
||||
say :: Color -> String
|
||||
say Red = "You are Red!"
|
||||
say Blue = "You are Blue!"
|
||||
say Green = "You are Green!"
|
||||
say Red = "You are Red!"
|
||||
say Blue = "You are Blue!"
|
||||
say Green = "You are Green!"
|
||||
|
||||
-- Your data types can have parameters too:
|
||||
|
||||
@ -384,8 +383,8 @@ main'' = do
|
||||
-- The type `IO` is an example of a "monad". The way Haskell uses a monad to
|
||||
-- do IO allows it to be a purely functional language. Any function that
|
||||
-- interacts with the outside world (i.e. does IO) gets marked as `IO` in its
|
||||
-- type signature. This lets us reason about what functions are "pure" (don't
|
||||
-- interact with the outside world or modify state) and what functions aren't.
|
||||
-- type signature. This lets us reason about which functions are "pure" (don't
|
||||
-- interact with the outside world or modify state) and which functions aren't.
|
||||
|
||||
-- This is a powerful feature, because it's easy to run pure functions
|
||||
-- concurrently; so, concurrency in Haskell is very easy.
|
||||
|
@ -118,11 +118,11 @@ public class LearnJava {
|
||||
*/
|
||||
|
||||
// Initialize a variable using <type> <name> = <val>
|
||||
int fooInt = 1;
|
||||
int barInt = 1;
|
||||
// Initialize multiple variables of same type with same
|
||||
// value <type> <name1>, <name2>, <name3> = <val>
|
||||
int fooInt1, fooInt2, fooInt3;
|
||||
fooInt1 = fooInt2 = fooInt3 = 1;
|
||||
int barInt1, barInt2, barInt3;
|
||||
barInt1 = barInt2 = barInt3 = 1;
|
||||
|
||||
/*
|
||||
* Variable types
|
||||
|
@ -2,7 +2,7 @@
|
||||
language: kdb+
|
||||
contributors:
|
||||
- ["Matt Doherty", "https://github.com/picodoc"]
|
||||
- ["Jonny Press", "jonny.press@aquaq.co.uk"]
|
||||
- ["Jonny Press", "https://github.com/jonnypress"]
|
||||
filename: learnkdb.q
|
||||
---
|
||||
|
||||
@ -26,6 +26,8 @@ separable so this distinction is not really useful.
|
||||
All Feedback welcome! You can reach me at matt.doherty@aquaq.co.uk, or Jonny
|
||||
at jonny.press@aquaq.co.uk
|
||||
|
||||
To learn more about kdb+ you can join the [Personal kdb+](https://groups.google.com/forum/#!forum/personal-kdbplus) or [TorQ kdb+](https://groups.google.com/forum/#!forum/kdbtorq) group.
|
||||
|
||||
```
|
||||
/ Single line comments start with a forward-slash
|
||||
/ These can also be used in-line, so long as at least one whitespace character
|
||||
|
254
lt-lt/tmux-lt.html.markdown
Normal file
254
lt-lt/tmux-lt.html.markdown
Normal file
@ -0,0 +1,254 @@
|
||||
---
|
||||
category: tool
|
||||
tool: tmux
|
||||
filename: tmux.json
|
||||
lang: lt-lt
|
||||
contributors:
|
||||
- ["mdln", "https://github.com/mdln"]
|
||||
translators:
|
||||
- ["Zygimantus", "https://github.com/zygimantus"]
|
||||
---
|
||||
|
||||
|
||||
[tmux](http://tmux.sourceforge.net)
|
||||
yra terminalo daugintuvas: jis leidžia vienu metu sukurti, turėti
|
||||
ir valdyti kelis terminalus viename ekrane. tmux gali būti atjungtas
|
||||
nuo ekrano ir veikti fone, o vėliau gali būti vėl prijungtas.
|
||||
|
||||
|
||||
```
|
||||
|
||||
tmux [komanda] # Vykdyti komandą
|
||||
# 'tmux' be komandų sukurs naują sesiją
|
||||
|
||||
new # Sukurti naują sesiją
|
||||
-s "Session" # Sukurti pavadintą sesiją
|
||||
-n "Window" # Sukurti pavadintą langą
|
||||
-c "/dir" # Pradėti nurodytoje direktorijoje
|
||||
|
||||
attach # Priskirti paskutinę/prienamą sesiją
|
||||
-t "#" # Priskirti nurodytą sesiją
|
||||
-d # Atjungti sesiją nuo kitų langų
|
||||
|
||||
ls # Aktyvių sesijų sąrašas
|
||||
-a # Visų aktyvių sesijų sąrašas
|
||||
|
||||
lsw # Langų sąrašas
|
||||
-a # Visų langų sąrašas
|
||||
-s # Visų langų sesijoje sąrašas
|
||||
|
||||
lsp # Skydelių sąrašas
|
||||
-a # Visų skydelių sąrašas
|
||||
-s # Visų skydelių sesijoje sąrašas
|
||||
-t # Visų skydelių taikinyje sąrašas
|
||||
|
||||
kill-window # Užbaigti dabartinį langą
|
||||
-t "#" # Užbaigti nurodytą langą
|
||||
-a # Užbaigti visus langus
|
||||
-a -t "#" # Užbaigti visus langus, bet ne taikinį
|
||||
|
||||
kill-session # Užbaigti dabartinę sesiją
|
||||
-t "#" # Užbaigti nurodytą sesiją
|
||||
-a # Užbaigti visas sesijas
|
||||
-a -t "#" # Užbaigti visas sesijas, bet ne taikinį
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Klavišai
|
||||
|
||||
Priskirta tmux sesija yra valdoma klavišų kompinacijomis.
|
||||
|
||||
```
|
||||
----------------------------------------------------------------------
|
||||
(C-b) = Ctrl + b # Kombinacija reikalinga norint naudoti klavišus
|
||||
|
||||
(M-1) = Meta + 1 -or- Alt + 1
|
||||
----------------------------------------------------------------------
|
||||
|
||||
? # Rodo visų klavišų kombinacijų sąrašą
|
||||
: # Įjungiama tmux komandinė eilutė
|
||||
r # Priverstinai perpiešiamas prijungtas klientas
|
||||
c # Sukurti naują langą
|
||||
|
||||
! # Iškelia esamą skydelį iš lango.
|
||||
% # Perskelia esamą skydelį į du, kairįjį ir dešinį
|
||||
" # Perskelia esamą skydelį į du, viršutinį ir apatinį
|
||||
|
||||
n # Pakeičia į kitą langą
|
||||
p # Pakeičia į buvusį langą
|
||||
{ # Apkeičia dabartinį skydėlį su buvusiu
|
||||
} # Apkeičia dabartinį skydėlį su sekančiu
|
||||
|
||||
s # Pasirinkti naują sesiją prijungtam klientui interaktyviai
|
||||
w # Pasirinkti dabartinį langą interaktyviai
|
||||
0 to 9 # Pasirinkti langą nuo 0 iki 9
|
||||
|
||||
d # Atjungti dabartinį klientą
|
||||
D # Pasirinkti klientą, kurį atjungti
|
||||
|
||||
& # Užbaigti dabartinį langą
|
||||
x # Užbaigti dabartinį skydelį
|
||||
|
||||
Up, Down # Pakeisti į skydelį viršuje, apačioje, kairėje arba
|
||||
dešinėje
|
||||
Left, Right
|
||||
|
||||
M-1 to M-5 # Rikiuoti skydelius:
|
||||
# 1) even-horizontal
|
||||
# 2) even-vertical
|
||||
# 3) main-horizontal
|
||||
# 4) main-vertical
|
||||
# 5) tiled
|
||||
|
||||
C-Up, C-Down # Keisti esamo skydelio dydį vienos ląstelės žingsniu
|
||||
C-Left, C-Right
|
||||
|
||||
M-Up, M-Down # Keisti esamo skydelio dydį penkių ląstelių žingsniu
|
||||
M-Left, M-Right
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Configuring ~/.tmux.conf
|
||||
|
||||
tmux.conf gali būti nustatytas automatiškai paleidimo metu, panašiai kaip ir
|
||||
.vimrc arba init.el.
|
||||
|
||||
```
|
||||
# Pavyzdys tmux.conf
|
||||
# 2014.10
|
||||
|
||||
|
||||
### General
|
||||
###########################################################################
|
||||
|
||||
# Enable UTF-8
|
||||
setw -g utf8 on
|
||||
set-option -g status-utf8 on
|
||||
|
||||
# Scrollback/History limit
|
||||
set -g history-limit 2048
|
||||
|
||||
# Index Start
|
||||
set -g base-index 1
|
||||
|
||||
# Mouse
|
||||
set-option -g mouse-select-pane on
|
||||
|
||||
# Force reload of config file
|
||||
unbind r
|
||||
bind r source-file ~/.tmux.conf
|
||||
|
||||
|
||||
### Keybinds
|
||||
###########################################################################
|
||||
|
||||
# Unbind C-b as the default prefix
|
||||
unbind C-b
|
||||
|
||||
# Set new default prefix
|
||||
set-option -g prefix `
|
||||
|
||||
# Return to previous window when prefix is pressed twice
|
||||
bind C-a last-window
|
||||
bind ` last-window
|
||||
|
||||
# Allow swapping C-a and ` using F11/F12
|
||||
bind F11 set-option -g prefix C-a
|
||||
bind F12 set-option -g prefix `
|
||||
|
||||
# Keybind preference
|
||||
setw -g mode-keys vi
|
||||
set-option -g status-keys vi
|
||||
|
||||
# Moving between panes with vim movement keys
|
||||
bind h select-pane -L
|
||||
bind j select-pane -D
|
||||
bind k select-pane -U
|
||||
bind l select-pane -R
|
||||
|
||||
# Window Cycle/Swap
|
||||
bind e previous-window
|
||||
bind f next-window
|
||||
bind E swap-window -t -1
|
||||
bind F swap-window -t +1
|
||||
|
||||
# Easy split pane commands
|
||||
bind = split-window -h
|
||||
bind - split-window -v
|
||||
unbind '"'
|
||||
unbind %
|
||||
|
||||
# Activate inner-most session (when nesting tmux) to send commands
|
||||
bind a send-prefix
|
||||
|
||||
|
||||
### Theme
|
||||
###########################################################################
|
||||
|
||||
# Statusbar Color Palatte
|
||||
set-option -g status-justify left
|
||||
set-option -g status-bg black
|
||||
set-option -g status-fg white
|
||||
set-option -g status-left-length 40
|
||||
set-option -g status-right-length 80
|
||||
|
||||
# Pane Border Color Palette
|
||||
set-option -g pane-active-border-fg green
|
||||
set-option -g pane-active-border-bg black
|
||||
set-option -g pane-border-fg white
|
||||
set-option -g pane-border-bg black
|
||||
|
||||
# Message Color Palette
|
||||
set-option -g message-fg black
|
||||
set-option -g message-bg green
|
||||
|
||||
# Window Status Color Palette
|
||||
setw -g window-status-bg black
|
||||
setw -g window-status-current-fg green
|
||||
setw -g window-status-bell-attr default
|
||||
setw -g window-status-bell-fg red
|
||||
setw -g window-status-content-attr default
|
||||
setw -g window-status-content-fg yellow
|
||||
setw -g window-status-activity-attr default
|
||||
setw -g window-status-activity-fg yellow
|
||||
|
||||
|
||||
### UI
|
||||
###########################################################################
|
||||
|
||||
# Notification
|
||||
setw -g monitor-activity on
|
||||
set -g visual-activity on
|
||||
set-option -g bell-action any
|
||||
set-option -g visual-bell off
|
||||
|
||||
# Automatically set window titles
|
||||
set-option -g set-titles on
|
||||
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program name,active (or not)
|
||||
|
||||
# Statusbar Adjustments
|
||||
set -g status-left "#[fg=red] #H#[fg=green]:#[fg=white]#S#[fg=green] |#[default]"
|
||||
|
||||
# Show performance counters in statusbar
|
||||
# Requires https://github.com/thewtex/tmux-mem-cpu-load/
|
||||
set -g status-interval 4
|
||||
set -g status-right "#[fg=green] | #[fg=white]#(tmux-mem-cpu-load)#[fg=green] | #[fg=cyan]%H:%M #[default]"
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Šaltiniai
|
||||
|
||||
[Tmux | Home](http://tmux.sourceforge.net)
|
||||
|
||||
[Tmux Manual page](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/tmux.1?query=tmux)
|
||||
|
||||
[Gentoo Wiki](http://wiki.gentoo.org/wiki/Tmux)
|
||||
|
||||
[Archlinux Wiki](https://wiki.archlinux.org/index.php/Tmux)
|
||||
|
||||
[Display CPU/MEM % in statusbar](https://stackoverflow.com/questions/11558907/is-there-a-better-way-to-display-cpu-usage-in-tmux)
|
||||
|
||||
[tmuxinator - Manage complex tmux sessions](https://github.com/tmuxinator/tmuxinator)
|
@ -138,18 +138,16 @@ while (condition) {
|
||||
|
||||
|
||||
# for loops and iteration
|
||||
for (my $i = 0; $i < $max; $i++) {
|
||||
for my $i (0 .. $max) {
|
||||
print "index is $i";
|
||||
}
|
||||
|
||||
for (my $i = 0; $i < @elements; $i++) {
|
||||
print "Current element is " . $elements[$i];
|
||||
}
|
||||
|
||||
for my $element (@elements) {
|
||||
print $element;
|
||||
}
|
||||
|
||||
map {print} @elements;
|
||||
|
||||
# implicitly
|
||||
|
||||
for (@elements) {
|
||||
|
@ -407,7 +407,7 @@ class Velocipede extends Bicicleta {
|
||||
|
||||
// Interfaces
|
||||
// Sintaxe de declaração de Interface
|
||||
// <nível de acesso> Interface <nome-da-interface> extends <super-interfaces> {
|
||||
// <nível de acesso> interface <nome-da-interface> extends <super-interfaces> {
|
||||
// // Constantes
|
||||
// // Declarações de método
|
||||
//}
|
||||
@ -415,11 +415,15 @@ class Velocipede extends Bicicleta {
|
||||
// Exemplo - Comida:
|
||||
public interface Comestivel {
|
||||
public void comer(); // Qualquer classe que implementa essa interface, deve
|
||||
// Implementar este método.
|
||||
// implementar este método.
|
||||
}
|
||||
|
||||
public interface Digestivel {
|
||||
public void digerir();
|
||||
// Em Java 8, interfaces podem ter métodos default.
|
||||
// public void digerir() {
|
||||
// System.out.println("digerindo ...");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -438,7 +442,7 @@ public class Fruta implements Comestivel, Digestivel {
|
||||
}
|
||||
|
||||
// Em Java, você pode estender somente uma classe, mas você pode implementar muitas
|
||||
// Interfaces. Por exemplo:
|
||||
// interfaces. Por exemplo:
|
||||
public class ClasseExemplo extends ExemploClassePai implements InterfaceUm,
|
||||
InterfaceDois {
|
||||
|
||||
@ -461,8 +465,8 @@ public class ClasseExemplo extends ExemploClassePai implements InterfaceUm,
|
||||
//}
|
||||
|
||||
// Marcar uma classe como abstrata significa que ela contém métodos abstratos que devem
|
||||
// ser definido em uma classe filha. Semelhante às interfaces, classes abstratas não podem
|
||||
// ser instanciadas, ao invés disso devem ser extendidas e os métodos abstratos
|
||||
// ser definidos em uma classe filha. Semelhante às interfaces, classes abstratas não podem
|
||||
// ser instanciadas, ao invés disso devem ser estendidas e os métodos abstratos
|
||||
// definidos. Diferente de interfaces, classes abstratas podem conter uma mistura de
|
||||
// métodos concretos e abstratos. Métodos em uma interface não podem ter um corpo,
|
||||
// a menos que o método seja estático, e as variáveis sejam finais, por padrão, ao contrário de um
|
||||
@ -482,7 +486,7 @@ public abstract class Animal
|
||||
|
||||
// Não há necessidade de inicializar, no entanto, em uma interface
|
||||
// a variável é implicitamente final e, portanto, tem
|
||||
// de ser inicializado.
|
||||
// de ser inicializada.
|
||||
protected int idade;
|
||||
|
||||
public void mostrarIdade()
|
||||
@ -501,7 +505,7 @@ class Cachorro extends Animal
|
||||
{
|
||||
|
||||
// Nota: ainda precisamos substituir os métodos abstratos na
|
||||
// classe abstrata
|
||||
// classe abstrata.
|
||||
@Override
|
||||
public void fazerSom()
|
||||
{
|
||||
@ -532,13 +536,13 @@ class Cachorro extends Animal
|
||||
//}
|
||||
|
||||
// Classes finais são classes que não podem ser herdadas e são, portanto, um
|
||||
// filha final. De certa forma, as classes finais são o oposto de classes abstratas
|
||||
// Porque classes abstratas devem ser estendidas, mas as classes finais não pode ser
|
||||
// filho final. De certa forma, as classes finais são o oposto de classes abstratas,
|
||||
// porque classes abstratas devem ser estendidas, mas as classes finais não podem ser
|
||||
// estendidas.
|
||||
public final class TigreDenteDeSabre extends Animal
|
||||
{
|
||||
// Nota: Ainda precisamos substituir os métodos abstratos na
|
||||
// classe abstrata.
|
||||
// classe abstrata.
|
||||
@Override
|
||||
public void fazerSom();
|
||||
{
|
||||
@ -552,7 +556,7 @@ public abstract class Mamifero()
|
||||
// Sintaxe de Métodos Finais:
|
||||
// <modificador-de-acesso> final <tipo-de-retorno> <nome-do-método>(<argumentos>)
|
||||
|
||||
// Métodos finais, como, classes finais não podem ser substituídas por uma classe filha,
|
||||
// Métodos finais, como classes finais, não podem ser substituídos por uma classe filha,
|
||||
// e são, portanto, a implementação final do método.
|
||||
public final boolean EImpulsivo()
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ contributors:
|
||||
- ["Amin Bandali", "http://aminbandali.com"]
|
||||
- ["Andre Polykanine", "https://github.com/Oire"]
|
||||
- ["evuez", "http://github.com/evuez"]
|
||||
- ["asyne", "https://github.com/justblah"]
|
||||
- ["habi", "http://github.com/habi"]
|
||||
filename: learnpython.py
|
||||
---
|
||||
@ -751,6 +752,24 @@ gen_to_list = list(values)
|
||||
print(gen_to_list) # => [-1, -2, -3, -4, -5]
|
||||
|
||||
# Decorators
|
||||
# A decorator is a higher order function, which accepts and returns a function.
|
||||
# Simple usage example – add_apples decorator will add 'Apple' element into
|
||||
# fruits list returned by get_fruits target function.
|
||||
def add_apples(func):
|
||||
def get_fruits():
|
||||
fruits = func()
|
||||
fruits.append('Apple')
|
||||
return fruits
|
||||
return get_fruits
|
||||
|
||||
@add_apples
|
||||
def get_fruits():
|
||||
return ['Banana', 'Mango', 'Orange']
|
||||
|
||||
# Prints out the list of fruits with 'Apple' element in it:
|
||||
# Banana, Mango, Orange, Apple
|
||||
print ', '.join(get_fruits())
|
||||
|
||||
# in this example beg wraps say
|
||||
# Beg will call say. If say_please is True then it will change the returned
|
||||
# message
|
||||
|
@ -289,7 +289,7 @@ nil ; 逻辑假,或者空列表
|
||||
;; (通过键)检索对应的值
|
||||
(gethash 'a *m*) ; => 1, t
|
||||
|
||||
;; 注意此处有一细节:Common Lisp往往返回多个值。`gethash`返回的两个值是t,代表找到了这个元素;返回nil表示没有找到这个元素。
|
||||
;; 注意此处有一细节:Common Lisp往往返回多个值。`gethash`返回的第二个值是t,代表找到了这个元素;返回nil表示没有找到这个元素。
|
||||
;;(译者注:返回的第一个值表示给定的键所对应的值或者nil;)
|
||||
;;(第二个是一个布尔值,表示在哈希表中是否存在这个给定的键)
|
||||
;; 例如,如果可以找到给定的键所对应的值,则返回一个t,否则返回nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user