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.1.0.41 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.40 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.39 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.38 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.37 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.36 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.34 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.33 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.32 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.31 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.30 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.29 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.28 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.27 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.26 tracks/vimscript/exercises/allergies/example.vim
trackler-2.1.0.25 tracks/vimscript/exercises/allergies/example.vim