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.180 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.179 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.178 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.177 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.176 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.175 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.174 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.173 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.172 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.171 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.170 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.169 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.167 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.166 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.165 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.164 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.163 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.162 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.161 tracks/vimscript/exercises/allergies/example.vim
trackler-2.2.1.160 tracks/vimscript/exercises/allergies/example.vim