Just because Exercism doesn’t offer your favorite language as an official track, it doesn’t mean we can’t play at all. Post some solutions to the weekly challenges in the language of your choice!

  • Andy@programming.devOPM
    link
    fedilink
    arrow-up
    1
    ·
    8 months ago
    Luhn, again
    USING: combinators.short-circuit.smart kernel math math.parser rosetta-code.luhn-test sequences sets unicode ;
    
    : ex-luhn? ( str -- ? )
      " " without
      dup {
        [ length 2 < ]
        [ [ digit? ] all? not ]
      } || [ drop f ] [
        string>number luhn?
      ] if
    ;
    
    Luhn, a third time
    USING: combinators.short-circuit.smart kernel math sequences sets unicode validators ;
    
    : ex-luhn? ( str -- ? )
      " " without
      dup {
        [ length 2 < ]
        [ [ digit? ] all? not ]
      } || [ drop f ] [ luhn? ] if
    ;