RosettaCodeData/Task/Bioinformatics-base-count/Jq/bioinformatics-base-count-1.jq
2023-07-01 13:44:08 -04:00

5 lines
239 B
Text

def lpad($len; $fill): tostring | ($len - length) as $l | ($fill * $l)[:$l] + .;
# Create a bag of words, i.e. a JSON object with counts of the items in the stream
def bow(stream):
reduce stream as $word ({}; .[($word|tostring)] += 1);