Модул:fun/doc
This is the documentation page for Модул:fun
fun маънои "функсионалӣ" -ро дорад, аммо барномасозии функсионалӣ низ метавонад шавқовар бошад. Ин китобхона дорои баъзе метафунксияҳои маъмулӣ барои барномасозии функсионалӣ мебошад, ба монанди map, some, all, curry, инчунин дигарон.
Функсияҳое, ки массивро ҳамчун аргументи дуюми худ мегиранд, ҳамчун усулҳо дар массивҳое, ки аз ҷониби Module:array сохта шудаанд, дастрасанд ва аргументҳо баръакс шудаанд, то онҳо ҳамчун метод номида шаванд.
Он дар қуттии корбар оғоз шуд (Module:User:Erutuon/functional). Онро бо Lua Fun омехта кардан мумкин нест (версияи он дар Module:User:Erutuon/luafun мавҷуд аст), гарчанде ки баъзе вазифаҳо ба ҳам монанданд.
Функсияҳое, ки ҷадвалро ҳамчун далели дуюми худ мегиранд, агар t[1] nil набошад, ҷадвалро ҳамчун массив баррасӣ мекунанд ва ipairs -ро истифода мебаранд. Дар акси ҳол, онҳо бо истифода аз pairs ба он ҳамчун hasmap муносибат мекунанд.
function map(func, iterable)- Perform a function
funcon every element initerableand return the resulting table.iterablemay be a table or a string. If a table, the function operates on every element in the array portion of the table; if a string, the function operates on every UTF-8 character in the string. The functionfunchas the following signature:func(member, i, iterable). That is, the table element or UTF-8 character is first, then the index of this element, and then the iterable value (table or string). function mapIter(func, iterator, iterable, initial_value)- Create a new array from the results of performing a function on the values returned by an iterator. Can be used in combination with
sortedPairsin Module:table.funchas the same signature described above. Not very useful withgmatch;funcwould have anilfirst argument, because the single value returned from the iterator would be supplied as the second argument tofunc. mapIter( function(parameter_value, parameter_name) return { parameter_name, parameter_value } end, sortedPairs(frame.args)) --> массиви мураттабшудаи массивҳоро, ки номҳо ва арзишҳои параметр доранд, бармегардонад