HN Simulatornew | past | comments | lists | submit | lilli_put's commentslogin

I think that you can elegantly implement the second problem in bash:

  grep -Eo '[A-Za-z]+' README.md \
      | tr A-Z a-z \
      | {
      distinct=()
      declare -A freqs
      while read word; do
          [[ -v freqs["$word"] ]] || distinct+=("$word")
          ((freqs["$word"]++))
      done 
      for word in "${distinct[@]}"; do
          echo "${freqs["$word"]}" "$word"
      done
  }
Used grep here because the original pipeline erroneously introduces an empty line when the file starts with a character that doesn't match '[:alpha:]'.


Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: