<commit_before>% The Computer Language Shootout                              
% http://shootout.alioth.debian.org/    
% contributed by <NAME>

functor
import Application Open

define
   fun {NextHeader F}
      case {F getS($)} 
      of false then false
      elseof &>|_ = Header then Header
      else {NextHeader F} end
   end

   fun {ReversedLines F L}
      case {F getS($)} 
      of false then L # false
      elseof &>|_ = Header then L # Header
      elseof &;|_ then {ReversedLines F L}
      elseof Line then {ReversedLines F Line|L} end
   end


   local
      fun {IubCodeComplements}
         Code = "ABCDGHKMNRSTVWYabcdghkmnrstvwy"
         Comp = "TVGHCDMKNYSABWRTVGHCDMKNYSABWR"
         A = {NewArray 1 &z &*}
      in
         {List.forAllInd 
            {List.zip Code Comp fun{$ A B} A#B end}
               proc{$ I K#V} A.K := V end}
         A
      end

      IUB = {IubCodeComplements}

   in
      proc {WriteReverseComplement FOut ReversedLines}
         FirstLine|RemainingLines = ReversedLines
         ShortestLength = {Length FirstLine}

         fun {ReverseComplement L C} IUB.C|L end

         fun {FastaReverseComplement I L C} 
            if I == ShortestLength then &\n|IUB.C|L 
            else IUB.C|L end 
         end

      in 
         {FOut write(vs: {FoldL FirstLine ReverseComplement nil}) }

         for Line in RemainingLines do
            {FOut write(vs: {List.foldLInd Line FastaReverseComplement nil})}
         end
         {FOut write(vs: "\n")}
      end
   end


   proc {ReadReverseComplementWrite F Header FOut}
      if Header \= false then 
         Lines # NextHeader = {ReversedLines F nil}
      in
         {FOut write(vs: Header # "\n")}<commit_msg>*** empty log message ***<commit_after>% The Computer Language Shootout                              
% http://shootout.alioth.debian.org/    
% contributed by <NAME>

functor
import Application Open

define
   fun {NextHeader F}
      case {F getS($)} 
      of false then false
      elseof &>|_ = Header then Header
      else {NextHeader F} end
   end

   fun {ReversedLines F L}
      case {F getS($)} 
      of false then L # false
      elseof &>|_ = Header then L # Header
      elseof &;|_ then {ReversedLines F L}
      elseof Line then {ReversedLines F Line|L} end
   end


   local
      fun {IubCodeComplements}
         Code = "ABCDGHKMNRSTVWYabcdghkmnrstvwy"
         Comp = "TVGHCDMKNYSABWRTVGHCDMKNYSABWR"
         A = {NewArray 1 &z &*}
      in
         {List.forAllInd 
            {List.zip Code Comp fun{$ A B} A#B end}
               proc{$ I K#V} A.K := V end}
         A
      end

      IUB = {IubCodeComplements}

   in
      proc {WriteReverseComplement FOut FirstLine|RemainingLines}
         ShortestLength = {Length FirstLine}

         fun {ReverseComplement L C} IUB.C|L end

         fun {FastaReverseComplement I L C} 
            if I == ShortestLength then &\n|IUB.C|L 
            else IUB.C|L end 
         end

      in 
         {FOut write(vs: {FoldL FirstLine ReverseComplement nil}) }

         for Line in RemainingLines do
            {FOut write(vs: {List.foldLInd Line FastaReverseComplement nil})}
         end
         {FOut write(vs: "\n")}
      end
   end


   proc {ReadReverseComplementWrite F Header FOut}
      if Header \= false then 
         Lines # NextHeader = {ReversedLines F nil}
      in
         {FOut write(vs: Header # "\n")}
{'fraction_non_alphanumeric': 0.08638360175695461, 'fraction_numerical': 0.0005856515373352855, 'mean_word_length': 1.8633696563285833, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5075572', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1078, 'n_words': 335}