Sha256: ca416635e35f7a38eee1bfb711e37d7bba4b99ff1c01789099c1a97f1698e61c

Contents?: true

Size: 587 Bytes

Versions: 216

Compression:

Stored size: 587 Bytes

Contents

let s:allergy_map = {
      \ 'eggs':         1,
      \ 'peanuts':      2,
      \ 'shellfish':    4,
      \ 'strawberries': 8,
      \ 'tomatoes':     16,
      \ 'chocolate':    32,
      \ 'pollen':       64,
      \ 'cats':         128,
      \ }

function! AllergicTo(score, allergy) abort
  return and(a:score, s:allergy_map[a:allergy]) != 0
endfunction

function! List(score) abort
  return filter(map(sort(items(s:allergy_map), 's:valsort'),
        \ 'v:val[0]'), 'AllergicTo(a:score, v:val)')
endfunction

function! s:valsort(a, b) abort
  return a:a[1] - a:b[1]
endfunction

Version data entries

216 entries across 216 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.158 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.157 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.156 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.155 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.154 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.153 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.152 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.151 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.150 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.149 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.148 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.147 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.146 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.145 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.144 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.143 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.142 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.141 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.140 tracks/vimscript/exercises/allergies/example.vim