|
|
|
@@ -0,0 +1,379 @@
|
|
|
|
|
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
|
|
|
|
|
{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Bold;\f1\fnil\fcharset0 HelveticaNeue-Italic;\f2\fnil\fcharset0 HelveticaNeue;
|
|
|
|
|
\f3\fmodern\fcharset0 CourierNewPS-BoldMT;\f4\fnil\fcharset0 HelveticaNeue-BoldItalic;\f5\fmodern\fcharset0 Courier-Bold;
|
|
|
|
|
\f6\fmodern\fcharset0 Courier-BoldOblique;\f7\fmodern\fcharset0 Courier-Oblique;\f8\fmodern\fcharset0 Courier;
|
|
|
|
|
\f9\fmodern\fcharset0 CourierNewPSMT;\f10\fmodern\fcharset0 CourierNewPS-ItalicMT;}
|
|
|
|
|
{\colortbl;\red255\green255\blue255;\red255\green255\blue255;\red230\green0\blue14;\red0\green0\blue0;
|
|
|
|
|
\red253\green129\blue123;\red32\green166\blue3;\red76\green76\blue76;\red13\green96\blue2;\red245\green174\blue9;
|
|
|
|
|
\red12\green97\blue171;\red189\green13\blue104;\red253\green128\blue8;}
|
|
|
|
|
{\*\expandedcolortbl;;\cssrgb\c100000\c100000\c100000;\cssrgb\c93213\c13483\c4656;\cssrgb\c0\c0\c0;
|
|
|
|
|
\cssrgb\c100000\c58874\c55293;\cssrgb\c11306\c69375\c172;\cssrgb\c37036\c37036\c37036;\cssrgb\c507\c44277\c174;\cssrgb\c97413\c73060\c0;
|
|
|
|
|
\cssrgb\c0\c46246\c72914;\cssrgb\c79662\c16222\c48278;\cssrgb\c100000\c57771\c0;}
|
|
|
|
|
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}
|
|
|
|
|
{\list\listtemplateid2\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid101\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid2}}
|
|
|
|
|
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}}
|
|
|
|
|
\paperw11905\paperh16837\margl1133\margr1133\margb1133\margt1133
|
|
|
|
|
\deftab720
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\b\fs22 \cf2 \cb3 \expnd0\expndtw0\kerning0
|
|
|
|
|
\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 local function strsplit(delimiter, text) \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f1\i\b0\fs18 \cf4 \cb5 \strokec4 if delimiter == "" then \
|
|
|
|
|
error("delimiter matches empty string!")\
|
|
|
|
|
end \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\i0\fs22 \cf4 \cb1 \strokec4 local list, pos, first, last = \{\}, 1\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f1\i\fs18 \cf4 \cb5 \strokec4 while true do \
|
|
|
|
|
first, last = text:find(delimiter, pos, true) \
|
|
|
|
|
if first then -- found? \
|
|
|
|
|
table.insert(list, text:sub(pos, first - 1))\
|
|
|
|
|
pos = last + 1 \
|
|
|
|
|
else \
|
|
|
|
|
table.insert(list, text:sub(pos)) \
|
|
|
|
|
break \
|
|
|
|
|
end \
|
|
|
|
|
end
|
|
|
|
|
\f2\i0\fs22 \cf4 \cb5 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf4 \cb1 \strokec4 return list\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\b \cf2 \cb3 \strokec2 end\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\b0 \cf4 \cb1 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\b \cf2 \cb6 \strokec2 M.private.strsplit = strsplit\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\b0 \cf4 \cb1 \strokec4 \
|
|
|
|
|
\
|
|
|
|
|
\
|
|
|
|
|
\pard\pardeftab720\qc\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\b\fs28 \cf3 \strokec3 A- \cf4 \ul \ulc4 \strokec4 ANALYSE DU CODE\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\fs22 \cf4 \ulc4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\b0 \cf4 \ulnone \strokec4 \'c0 premi\'e8re vue, on remarque que notre bout de code est constitu\'e9 de deux partie s\'e9par\'e9es.\
|
|
|
|
|
\
|
|
|
|
|
\pard\pardeftab720\qc\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\b\fs28 \cf3 \strokec3 1-
|
|
|
|
|
\fs20 \cf3 \strokec3
|
|
|
|
|
\f2\b0\fs26 \cf4 \ul \ulc4 \strokec4 Un bloc d\'e9limit\'e9 par:
|
|
|
|
|
\fs20 \cf4 \ulnone \strokec4
|
|
|
|
|
\f3\b \cf7 \strokec7 local function strsplit(delimiter, text) \'85\'85\'85 end
|
|
|
|
|
\f2\b0 \cf4 \strokec4 (en rouge)\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\fs22 \cf4 \ul \ulc4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf4 \ulnone \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\b\fs26 \cf3 \cb5 \strokec3 local function\cf4 \cb5 \strokec4 \cf8 \cb5 \strokec8 strsplit\cf9 \cb5 \strokec9 (delimiter, text) \cf4 \cb5 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\b0\fs22 \cf4 \cb1 \strokec4
|
|
|
|
|
\f0\b \cf3 \strokec3
|
|
|
|
|
\f4\i \cf3 \strokec3 if \cf10 \strokec10 delimiter
|
|
|
|
|
\f1\b0 \cf4 \strokec4
|
|
|
|
|
\f4\b \cf3 \strokec3 ==
|
|
|
|
|
\f1\b0 \cf4 \strokec4
|
|
|
|
|
\fs26 \cf11 \strokec11 ""
|
|
|
|
|
\fs22 \cf4 \strokec4
|
|
|
|
|
\f4\b \cf3 \strokec3 then\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f1\b0 \cf4 \strokec4
|
|
|
|
|
\f4\b \cf6 \strokec6 error
|
|
|
|
|
\fs32 \cf12 \strokec12 (
|
|
|
|
|
\f1\b0\fs22 \cf11 \strokec11 "delimiter matches empty string!"
|
|
|
|
|
\f4\b\fs32 \cf12 \strokec12 )
|
|
|
|
|
\f1\b0\fs22 \cf4 \strokec4 \
|
|
|
|
|
|
|
|
|
|
\f4\b \cf3 \strokec3 end
|
|
|
|
|
\f1\b0 \cf4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\i0 \cf4 \strokec4
|
|
|
|
|
\f0\b \cf3 \strokec3 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\fs28 \cf3 \strokec3 local
|
|
|
|
|
\f2\b0 \cf4 \strokec4
|
|
|
|
|
\f0\b \cf10 \strokec10 list, pos, first, last
|
|
|
|
|
\f2\b0 \cf4 \strokec4 \cf3 \strokec3 =\cf4 \strokec4
|
|
|
|
|
\f0\b \cf3 \strokec3 \{\}
|
|
|
|
|
\f2\b0 \cf4 \strokec4 , 1\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\fs22 \cf4 \strokec4
|
|
|
|
|
\f0\b \cf4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f5\fs24 \cf3 \strokec3
|
|
|
|
|
\f6\i \cf3 \strokec3 while
|
|
|
|
|
\f7\b0 \cf3 \strokec3 true do\cf4 \strokec4 \
|
|
|
|
|
|
|
|
|
|
\f6\b \cf10 \strokec10 first, last
|
|
|
|
|
\f7\b0 \cf4 \strokec4 =
|
|
|
|
|
\f6\b \cf4 \strokec4 text:\cf6 \strokec6 find\cf12 \strokec12 (delimiter, pos
|
|
|
|
|
\f7\b0 \cf12 \strokec12 ,
|
|
|
|
|
\f6\b \cf12 \strokec12 true)
|
|
|
|
|
\f7\b0 \cf12 \strokec12 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf4 \strokec4
|
|
|
|
|
\f6\b \cf3 \strokec3 if
|
|
|
|
|
\f7\b0 \cf4 \strokec4 \cf3 \strokec3 first then\cf4 \strokec4 --
|
|
|
|
|
\f6\b \cf3 \strokec3 found?\
|
|
|
|
|
|
|
|
|
|
\f7\b0 \cf4 \strokec4
|
|
|
|
|
\f6\b \cf4 \strokec4 table\cf3 \strokec3 .\cf6 \strokec6 insert
|
|
|
|
|
\f7\b0 \cf4 \strokec4 (
|
|
|
|
|
\f6\b \cf10 \strokec10 list
|
|
|
|
|
\f7\b0 \cf4 \strokec4 ,
|
|
|
|
|
\f6\b \cf4 \strokec4 text:\cf6 \strokec6 sub\cf12 \strokec12 (pos, first - 1))
|
|
|
|
|
\f7\b0 \cf4 \strokec4 \
|
|
|
|
|
|
|
|
|
|
\f6\b \cf10 \strokec10 pos \cf3 \strokec3 =\cf10 \strokec10 last
|
|
|
|
|
\f7\b0 \cf4 \strokec4 + 1\
|
|
|
|
|
|
|
|
|
|
\f6\b \cf3 \strokec3 else\
|
|
|
|
|
|
|
|
|
|
\f7\b0 \cf4 \strokec4
|
|
|
|
|
\f6\b \cf4 \strokec4 table\cf3 \strokec3 .\cf6 \strokec6 insert\cf12 \strokec12 (
|
|
|
|
|
\f7\b0 \cf12 \strokec12 list,
|
|
|
|
|
\f6\b \cf12 \strokec12 text:\cf6 \strokec6 sub
|
|
|
|
|
\f7\b0 \cf12 \strokec12 (pos)
|
|
|
|
|
\f6\b \cf12 \strokec12 )
|
|
|
|
|
\f7\b0 \cf12 \strokec12 \
|
|
|
|
|
\cf4 \strokec4
|
|
|
|
|
\f6\b \cf3 \strokec3 break
|
|
|
|
|
\f7\b0 \cf4 \strokec4 \
|
|
|
|
|
|
|
|
|
|
\f6\b \cf3 \strokec3 end
|
|
|
|
|
\f7\b0 \cf4 \strokec4 \
|
|
|
|
|
|
|
|
|
|
\f6\b \cf3 \strokec3 end\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f8\i0\b0 \cf4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\fs22 \cf4 \strokec4
|
|
|
|
|
\f0\b \cf3 \strokec3 return
|
|
|
|
|
\f2\b0 \cf4 \strokec4
|
|
|
|
|
\f0\b \cf10 \strokec10 list\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\fs26 \cf3 \cb5 \strokec3 end \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\b0\fs22 \cf4 \cb1 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\b\fs24 \cf4 \strokec4 \
|
|
|
|
|
\
|
|
|
|
|
\
|
|
|
|
|
\
|
|
|
|
|
\
|
|
|
|
|
Dans cette 1\'e8re partie on a:\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\b0\fs22 \cf4 \ul \ulc4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf2 \cb3 \ulnone \strokec2 EN ROUGE:\cf4 \cb1 \strokec4 Les mots cl\'e9 du langage
|
|
|
|
|
\f1\i\fs16 \cf4 \strokec4 (je pense au C++)
|
|
|
|
|
\f2\i0\fs22 \cf4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf2 \cb12 \strokec2 EN ORANGE et
|
|
|
|
|
\f0\b\fs32 \cf2 \cb12 \strokec2 ( )
|
|
|
|
|
\f2\b0\fs22 \cf2 \cb12 \strokec2 :\cf4 \cb12 \strokec4 \cf4 \cb1 \strokec4 Les param\'e8tres de la fonction
|
|
|
|
|
\f0\b \cf4 \strokec4 strsplit()
|
|
|
|
|
\f2\b0 \cf4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf2 \cb10 \strokec2 EN BLEU: \cf4 \cb10 \strokec4 les variables\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf2 \cb6 \strokec2 EN VERT: \cf4 \cb6 \strokec4 Les noms de fonction\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf2 \cb3 \strokec2 EN NOIR: \cf4 \cb1 \strokec4 Non identifier \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf2 \cb11 \strokec2 EN VIOLET: \cf2 \cb1 \strokec2 \cf4 \strokec4 Chaine de caract\'e8res\
|
|
|
|
|
\
|
|
|
|
|
\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\b\fs28 \cf3 \strokec3 1-
|
|
|
|
|
\fs22 \cf3 \strokec3
|
|
|
|
|
\f2\b0\fs26 \cf4 \ul \ulc4 \strokec4 Un second bloc en dehors de la fonction representer par une seule instruction:
|
|
|
|
|
\f8\fs28 \cf7 \ulnone \strokec7 M.private.strsplit = strsplit
|
|
|
|
|
\fs24 \cf4 \strokec4 (en vert)\
|
|
|
|
|
\pard\pardeftab720\qc\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f5\b \cf4 \ul \ulc4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\qc\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\fs28 \cf3 \ulnone \strokec3 B- \cf4 \ul \ulc4 \strokec4 INTERPRETATION ET COMPR\'c9HENSION DU CODE\
|
|
|
|
|
\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\fs24 \cf4 \ulnone \strokec4 //
|
|
|
|
|
\f2\b0 \cf3 \strokec3
|
|
|
|
|
\f3\b \cf3 \strokec3 local function strsplit(delimiter, text) \'85\'85\'85 end
|
|
|
|
|
\f0 \cf3 \strokec3 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f8\b0 \cf4 \strokec4 En g\'e9n\'e9ral nous avons une fonction appel\'e9e \cf7 \strokec7 strsplit() \cf4 \strokec4 qui prend en param\'e8tre un caract\'e8re de s\'e9paration appel\'e9 (\cf7 \strokec7 delimiter\cf4 \strokec4 ) et le texte (\cf7 \strokec7 text\cf4 \strokec4 ) \'e0 d\'e9couper en caract\'e8re comme l\'92indique le nom de la fonction (
|
|
|
|
|
\fs28 \cf7 \strokec7 strsplit
|
|
|
|
|
\fs24 \cf4 \strokec4 )\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f2\fs22 \cf4 \strokec4 \
|
|
|
|
|
\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f0\b\fs26 \cf4 \strokec4 //\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f8\b0\fs22 \cf4 \strokec4 \cf3 \strokec3 if \cf10 \strokec10 delimiter\cf4 \strokec4 \cf3 \strokec3 ==\cf4 \strokec4
|
|
|
|
|
\fs26 \cf11 \strokec11 ""
|
|
|
|
|
\fs22 \cf4 \strokec4 \cf3 \strokec3 then\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf4 \strokec4 \cf6 \strokec6 error
|
|
|
|
|
\fs32 \cf12 \strokec12 (
|
|
|
|
|
\fs22 \cf11 \strokec11 "delimiter matches empty string!"
|
|
|
|
|
\fs32 \cf12 \strokec12 )
|
|
|
|
|
\fs22 \cf4 \strokec4 \
|
|
|
|
|
\cf3 \strokec3 end\
|
|
|
|
|
\cf4 \strokec4 \
|
|
|
|
|
Dans cette partie, on a un premier bloc
|
|
|
|
|
\f5\b \cf3 \strokec3 if \'85\'85
|
|
|
|
|
\f8\b0 \cf4 \strokec4
|
|
|
|
|
\f5\b \cf3 \strokec3 end
|
|
|
|
|
\f8\b0 \cf4 \strokec4 qui compare la variable
|
|
|
|
|
\f5\b \cf10 \strokec10 delimiter
|
|
|
|
|
\f8\b0 \cf4 \strokec4 \'e0 un caract\'e8re vide
|
|
|
|
|
\f5\b\fs26 \cf11 \strokec11 ""
|
|
|
|
|
\f8\b0\fs22 \cf4 \strokec4 et renvoie un message d\'92erreur si l\'92instruction:
|
|
|
|
|
\f5\b \cf10 \strokec10 delimiter
|
|
|
|
|
\f8\b0 \cf4 \strokec4
|
|
|
|
|
\f5\b \cf3 \strokec3 ==
|
|
|
|
|
\f8\b0 \cf4 \strokec4
|
|
|
|
|
\fs26 \cf11 \strokec11 "" \cf4 \strokec4 renvoie \cf3 \strokec3 true\
|
|
|
|
|
\
|
|
|
|
|
\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f5\b\fs22 \cf4 \strokec4 //\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f3\fs28 \cf3 \strokec3 local
|
|
|
|
|
\f9\b0 \cf4 \strokec4 \cf10 \strokec10 list, pos, first, last\cf4 \strokec4 \cf3 \strokec3 =\cf4 \strokec4 \cf3 \strokec3 \{\}\cf4 \strokec4 , 1
|
|
|
|
|
\f2\fs20 \cf4 \strokec4 => Affectation multiple\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f8\fs22 \cf4 \strokec4 ici 4 variables
|
|
|
|
|
\f5\b \cf10 \strokec10 list, pos, first, last
|
|
|
|
|
\f8\b0 \cf4 \strokec4 sont initialis\'e9e o\'f9 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f9\fs28 \cf10 \strokec10 list = \cf3 \strokec3 \{\}
|
|
|
|
|
\f2\fs20 \cf4 \strokec4 => hash vide
|
|
|
|
|
\f9\fs28 \cf3 \strokec3 \
|
|
|
|
|
\cf10 \strokec10 pos = \cf3 \strokec3 1\
|
|
|
|
|
\cf10 \strokec10 first = \cf3 \strokec3 nil\
|
|
|
|
|
\cf10 \strokec10 last = \cf3 \strokec3 nil
|
|
|
|
|
\f10\i \cf4 \ul \ulc4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f5\i0\b\fs22 \cf4 \ulnone \strokec4 //\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f8\b0\fs24 \cf3 \strokec3 while true do\cf4 \strokec4 \
|
|
|
|
|
\cf10 \strokec10 first, last\cf4 \strokec4 = text:\cf6 \strokec6 find\cf12 \strokec12 (delimiter, pos, true)\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
\cf4 \strokec4 \cf3 \strokec3 if\cf4 \strokec4
|
|
|
|
|
\f5\b \cf10 \strokec10 first
|
|
|
|
|
\f8\b0 \cf3 \strokec3 then\cf4 \strokec4 -- \cf3 \strokec3 found?\
|
|
|
|
|
\cf4 \strokec4 table\cf3 \strokec3 .\cf6 \strokec6 insert\cf4 \strokec4 (\cf10 \strokec10 list\cf4 \strokec4 , \cf4 \strokec4 text:\cf6 \strokec6 sub\cf12 \strokec12 (pos, first - 1))\cf4 \strokec4 \
|
|
|
|
|
\cf10 \strokec10 pos \cf3 \strokec3 =\cf10 \strokec10 last\cf4 \strokec4 + 1\
|
|
|
|
|
\cf3 \strokec3 else\
|
|
|
|
|
\cf4 \strokec4 table\cf3 \strokec3 .\cf6 \strokec6 insert\cf12 \strokec12 (list, text:\cf6 \strokec6 sub\cf12 \strokec12 (pos))\
|
|
|
|
|
\cf4 \strokec4 \cf3 \strokec3 break\cf4 \strokec4 \
|
|
|
|
|
\cf3 \strokec3 end\cf4 \strokec4 \
|
|
|
|
|
\cf3 \strokec3 end\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\fs22 \cf4 \strokec4 ici on a un bloc (
|
|
|
|
|
\f5\b \cf3 \strokec3 if \'85\'85
|
|
|
|
|
\f8\b0 \cf4 \strokec4
|
|
|
|
|
\f5\b \cf3 \strokec3 end
|
|
|
|
|
\f8\b0 \cf4 \strokec4 ) imbriqu\'e9 dans un bloc (
|
|
|
|
|
\f5\b \cf3 \strokec3 while \'85\'85
|
|
|
|
|
\f8\b0 \cf4 \strokec4
|
|
|
|
|
\f5\b \cf3 \strokec3 end
|
|
|
|
|
\f8\b0 \cf4 \strokec4 ) qui est toujours \'e0 \cf3 \strokec3 true,\cf4 \strokec4 synonyme de boucle infini.\
|
|
|
|
|
Le but de la boucle ici c\'92est de:\
|
|
|
|
|
\pard\tx20\tx260\pardeftab720\li240\fi-240\partightenfactor0
|
|
|
|
|
\ls1\ilvl0
|
|
|
|
|
\fs24\fsmilli12000 \cf4 \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 {\listtext - }
|
|
|
|
|
\fs20 \cf4 \expnd0\expndtw0\kerning0
|
|
|
|
|
\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec4 D\'92abord ex\'e9cuter l\'92instruction: \cf10 \strokec10 first, last\cf4 \strokec4 = text:\cf6 \strokec6 find\cf12 \strokec12 (delimiter, pos, true) \cf4 \strokec4 qui recherche s\'92il existe un delimiter fourni en param\'e8tre en position 1, \'e0 la fonction
|
|
|
|
|
\f3\b\fs24 \cf4 \strokec4 strsplit
|
|
|
|
|
\f8\b0\fs20 \cf4 \strokec4 et l\'92affecte aux variables \cf10 \strokec10 first.\
|
|
|
|
|
\ls1\ilvl0
|
|
|
|
|
\fs24\fsmilli12000 \cf4 \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 {\listtext - }
|
|
|
|
|
\fs20 \cf4 \expnd0\expndtw0\kerning0
|
|
|
|
|
\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec4 S\'92il trouve un delimiter, il rentre dans le
|
|
|
|
|
\f5\b \cf3 \strokec3 if
|
|
|
|
|
\f8\b0 \cf4 \strokec4 et ex\'e9cute ceci:\cf10 \strokec10 \cf4 \strokec4
|
|
|
|
|
\f5\b\fs22 \cf4 \strokec4 table\cf3 \strokec3 .\cf6 \strokec6 insert\cf4 \strokec4 (\cf10 \strokec10 list\cf4 \strokec4 , \cf4 \strokec4 text:\cf6 \strokec6 sub\cf12 \strokec12 (pos, first - 1))\cf4 \strokec4 \
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\f8\b0\fs24 \cf4 \strokec4 \cf10 \strokec10 pos \cf3 \strokec3 =\cf10 \strokec10 last\cf4 \strokec4 + 1,\
|
|
|
|
|
\pard\pardeftab720\partightenfactor0
|
|
|
|
|
|
|
|
|
|
\fs20 \cf4 \strokec4 increment la variable
|
|
|
|
|
\f5\b\fs24 \cf10 \strokec10 pos
|
|
|
|
|
\f8\b0\fs20 \cf4 \strokec4 de 1 pour d\'e9placer la position du
|
|
|
|
|
\f5\b \cf10 \strokec10 delimiter
|
|
|
|
|
\f8\b0 \cf4 \strokec4 dans le texte, ajoute le mot trouv\'e9 \'e0 la collection
|
|
|
|
|
\f5\b\fs22 \cf10 \strokec10 list
|
|
|
|
|
\f8\b0\fs20 \cf4 \strokec4 puis rentre dans une nouvelle it\'e9ration du
|
|
|
|
|
\f5\b \cf3 \strokec3 while
|
|
|
|
|
\f8\b0 \cf4 \strokec4 et
|
|
|
|
|
\f5\b \cf3 \strokec3
|
|
|
|
|
\f8\b0 \cf4 \strokec4 ainsi de suite.\cf10 \strokec10 \
|
|
|
|
|
\pard\tx20\tx260\pardeftab720\li240\fi-240\partightenfactor0
|
|
|
|
|
\ls2\ilvl0
|
|
|
|
|
\fs24\fsmilli12000 \cf4 \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 {\listtext - }
|
|
|
|
|
\fs20 \cf4 \expnd0\expndtw0\kerning0
|
|
|
|
|
\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec4 sinon (
|
|
|
|
|
\f5\b \cf3 \strokec3 else
|
|
|
|
|
\f8\b0 \cf4 \strokec4 ), il ex\'e9cute:\cf10 \strokec10 \cf4 \strokec4 table\cf3 \strokec3 .\cf6 \strokec6 insert\cf12 \strokec12 (list, text:\cf6 \strokec6 sub\cf12 \strokec12 (pos))\
|
|
|
|
|
\ls2\ilvl0
|
|
|
|
|
\fs24\fsmilli12000 \cf4 \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 {\listtext - }
|
|
|
|
|
\fs20 \cf4 \expnd0\expndtw0\kerning0
|
|
|
|
|
\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec4 Et arr\'eate l\'92ex\'e9cution de la boucle
|
|
|
|
|
\f5\b \cf3 \strokec3 while
|
|
|
|
|
\f8\b0 \cf4 \strokec4 avec\cf12 \strokec12 \cf3 \strokec3 break\
|
|
|
|
|
\ls2\ilvl0
|
|
|
|
|
\fs24\fsmilli12000 \cf4 \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 {\listtext - }
|
|
|
|
|
\fs20 \cf4 \expnd0\expndtw0\kerning0
|
|
|
|
|
\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec4 et retourne la variable
|
|
|
|
|
\f5\b \cf10 \strokec10 list
|
|
|
|
|
\f8\b0 \cf4 \strokec4 avec toute la collection de mots trouv\'e9s:\cf3 \strokec3 \cf4 \strokec4
|
|
|
|
|
\f5\b \cf3 \strokec3 return
|
|
|
|
|
\f8\b0 \cf4 \strokec4
|
|
|
|
|
\f5\b \cf10 \strokec10 list\
|
|
|
|
|
}
|