mirror of
https://github.com/inkarkat/vim-ingo-library.git
synced 2026-05-29 11:18:51 +02:00
CHG: Move ingo#list#Matches() to ingo#list#pattern#AllItemsMatch()
The previous name wasn't very clear.
This commit is contained in:
@@ -101,6 +101,8 @@ HISTORY
|
||||
- Tweak ingo#avoidprompt#MaxLength() algorithm; empirical testing showed that
|
||||
1 more needs to be subtracted if :set noshowcmd ruler. Thanks to an9wer for
|
||||
making me aware of this.
|
||||
- CHG: Move ingo#list#Matches() to ingo#list#pattern#AllItemsMatch(). The
|
||||
previous name wasn't very clear.
|
||||
|
||||
##### 1.034 13-Feb-2018
|
||||
- Add ingo/regexp/split.vim module.
|
||||
|
||||
+2
-19
@@ -2,7 +2,7 @@
|
||||
"
|
||||
" DEPENDENCIES:
|
||||
"
|
||||
" Copyright: (C) 2013-2017 Ingo Karkat
|
||||
" Copyright: (C) 2013-2018 Ingo Karkat
|
||||
" The VIM LICENSE applies to this script; see ':help copyright'.
|
||||
"
|
||||
" Maintainer: Ingo Karkat <ingo@karkat.de>
|
||||
@@ -33,7 +33,7 @@ endfunction
|
||||
function! ingo#list#AddOrExtend( list, val, ... )
|
||||
"******************************************************************************
|
||||
"* PURPOSE:
|
||||
" Add a:val as element(s) to a:list. Extends a List, adds other types.
|
||||
" Add a:val as item(s) to a:list. Extends a List, adds other types.
|
||||
"* ASSUMPTIONS / PRECONDITIONS:
|
||||
" None.
|
||||
"* EFFECTS / POSTCONDITIONS:
|
||||
@@ -188,21 +188,4 @@ function! ingo#list#JoinNonEmpty( list, ... )
|
||||
return call('join', [ingo#list#NonEmpty(a:list)] + a:000)
|
||||
endfunction
|
||||
|
||||
function! ingo#list#Matches( list, expr )
|
||||
"******************************************************************************
|
||||
"* PURPOSE:
|
||||
" Test whether each element of the list matches the regular expression.
|
||||
"* ASSUMPTIONS / PRECONDITIONS:
|
||||
" None.
|
||||
"* EFFECTS / POSTCONDITIONS:
|
||||
" None.
|
||||
"* INPUTS:
|
||||
" a:list A list.
|
||||
" a:expr Regular expression.
|
||||
"* RETURN VALUES:
|
||||
" 1 if all items of a:list match a:expr; else 0.
|
||||
"******************************************************************************
|
||||
return empty(filter(copy(a:list), 'v:val !~# a:expr'))
|
||||
endfunction
|
||||
|
||||
" vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax :
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
" ingo/list/pattern.vim: Functions for applying a regular expression to List items.
|
||||
"
|
||||
" DEPENDENCIES:
|
||||
"
|
||||
" Copyright: (C) 2018 Ingo Karkat
|
||||
" The VIM LICENSE applies to this script; see ':help copyright'.
|
||||
"
|
||||
" Maintainer: Ingo Karkat <ingo@karkat.de>
|
||||
|
||||
function! ingo#list#pattern#AllItemsMatch( list, expr )
|
||||
"******************************************************************************
|
||||
"* PURPOSE:
|
||||
" Test whether each item of the list matches the regular expression.
|
||||
"* ASSUMPTIONS / PRECONDITIONS:
|
||||
" None.
|
||||
"* EFFECTS / POSTCONDITIONS:
|
||||
" None.
|
||||
"* INPUTS:
|
||||
" a:list A list.
|
||||
" a:expr Regular expression.
|
||||
"* RETURN VALUES:
|
||||
" 1 if all items of a:list match a:expr; else 0.
|
||||
"******************************************************************************
|
||||
return empty(filter(copy(a:list), 'v:val !~# a:expr'))
|
||||
endfunction
|
||||
|
||||
" vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax :
|
||||
@@ -7,7 +7,7 @@
|
||||
" - ingo/list/lcs.vim autoload script
|
||||
" - ingo/list/sequence.vim autoload script
|
||||
"
|
||||
" Copyright: (C) 2017 Ingo Karkat
|
||||
" Copyright: (C) 2017-2018 Ingo Karkat
|
||||
" The VIM LICENSE applies to this script; see ':help copyright'.
|
||||
"
|
||||
" Maintainer: Ingo Karkat <ingo@karkat.de>
|
||||
@@ -151,7 +151,7 @@ function! s:Create( options, distinctList, isWrap )
|
||||
endif
|
||||
|
||||
let [l:sequenceLen, l:stride] = ingo#list#sequence#FindNumerical(a:distinctList)
|
||||
if l:sequenceLen <= 2 || ! ingo#list#Matches(a:distinctList[0 : l:sequenceLen - 1], '^\d\+$')
|
||||
if l:sequenceLen <= 2 || ! ingo#list#pattern#AllItemsMatch(a:distinctList[0 : l:sequenceLen - 1], '^\d\+$')
|
||||
let [l:sequenceLen, l:stride] = ingo#list#sequence#FindCharacter(a:distinctList)
|
||||
endif
|
||||
if l:sequenceLen > 2
|
||||
|
||||
@@ -115,6 +115,8 @@ HISTORY *ingo-library-history*
|
||||
- Tweak ingo#avoidprompt#MaxLength() algorithm; empirical testing showed that
|
||||
1 more needs to be subtracted if :set noshowcmd ruler. Thanks to an9wer for
|
||||
making me aware of this.
|
||||
- CHG: Move ingo#list#Matches() to ingo#list#pattern#AllItemsMatch(). The
|
||||
previous name wasn't very clear.
|
||||
|
||||
1.034 13-Feb-2018
|
||||
- Add ingo/regexp/split.vim module.
|
||||
|
||||
@@ -87,6 +87,7 @@ autoload/ingo/lines/replace.vim
|
||||
autoload/ingo/list.vim
|
||||
autoload/ingo/list/find.vim
|
||||
autoload/ingo/list/lcs.vim
|
||||
autoload/ingo/list/pattern.vim
|
||||
autoload/ingo/list/sequence.vim
|
||||
autoload/ingo/list/split.vim
|
||||
autoload/ingo/lists/find.vim
|
||||
|
||||
Reference in New Issue
Block a user