Jump to content

Greatest element of a list: Difference between revisions

→‎{{header|Vim Script}}: Fix indentation (tabs → spaces)
(→‎Joy: add)
(→‎{{header|Vim Script}}: Fix indentation (tabs → spaces))
Line 4,534:
for strings (with configurable ignore-case):
<syntaxhighlight lang="vim">function! Max(list, ...)
" {list} list of strings
" {a:1} 'i': ignore case, 'I': match case, otherwise use 'ignorecase' option
if empty(a:list)
return 0
endif
let gt_op = a:0>=1 ? get({'i': '>?', 'I': '>#'}, a:1, '>') : '>'
Line 4,545:
let idx = 1
while idx < len
if eval(cmp_expr)
let maxval = a:list[idx]
endif
let idx += 1
endwhile
return maxval
1

edit

Cookies help us deliver our services. By using our services, you agree to our use of cookies.