list_insertSyntaxeListInsert(Lst, Nro, Itm) Insère un élément dans une liste à un endroit précis. Trois paramètres : 1. La liste à modifier (Lst) au format liste. 2. La place de l' élément à insérer (Nro) au format nombre. 3. L' élément à insérer (Itm) (tous formats) Le résultat est au format liste. Par Fredo d;o) ExempleListInsert({"Un", "Deux", "Quatre", "Cinq"}, 3,"Trois") ---> {"Un", "Deux", "Trois", "Quatre", "Cinq"} Scripton ListInsert(Lst, Nro, Itm) set NbrItms to (length of Lst) if (NbrItms is 0) or (Nro is 0) then return Lst if (Nro > NbrItms) then return (Lst & Itm) as list else if (Nro < -NbrItms) then return ({Itm} & Lst) as list else if (Nro ² NbrItms) and (Nro > 0) then return (items 1 thru (Nro - 1) of Lst) & ¬ Itm & (items Nro thru -1 of Lst) else if (Nro ³ -NbrItms) and (Nro < 0) then return (items 1 thru (Nro) of Lst) & ¬ Itm & (items (Nro + 1) thru -1 of Lst) else return Lst end if end ListInsert
|