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.98 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.97 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.96 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.95 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.94 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.93 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.92 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.91 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.90 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.89 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.88 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.87 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.86 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.85 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.84 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.83 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.82 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.81 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.80 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.79 tracks/vimscript/exercises/allergies/example.vim