Paste: Weird stack effect issue

Author: nomennescio
Mode: factor
Date: Fri, 22 Jul 2022 21:24:16
Plain Text |
! test code

USING: kata tools.testest ;
IN: kata.tests

: run-tests ( -- )
  "Your order, please" describe#{
    "Sample test cases" it#{
      <{ "is2 Thi1s T4est 3a" order -> "Thi1s is2 3a T4est" }>
      <{ "4of Fo1r pe6ople g3ood th5e the2" order -> "Fo1r the2 g3ood 4of th5e pe6ople" }>
      <{ "" order -> "" }>
    }#
  }#
;

MAIN: run-tests

! actual code
USING: ascii kernel math.order sequences sorting splitting ;

: order ( str -- str' ) " " split  [ [ [ digit? ] find nip ] bi@ <=> ] sort " " join ;

New Annotation

Summary:
Author:
Mode:
Body: