Ad
Y = \f.(\x.f(x x))(\x.f(x x))

pred = \ n f x . n (\ g h . h (g f)) (\ _ . x) (\ x . x)
sub = \ m n . n pred m

True = \ a b . a
False = \ a b . b

is-zero = \ n . n (\ _ . False) True

mod = Y(\F.(\a.\b.((is-zero(sub b(sub a 1))((\c.\d.\e.(c)))(((is-zero(sub a(sub b 1))))(\c.\d.\e.(d))((\c.\d.\e.(e))))))(((F(sub a b))b))(a)0))
hyperop = (\f.(\x.f(x x))(\x.f(x x))) (\f.\s.\a.\n.  s(\x.\a.\b.b)(\a.\b.a)   (\x.a(n x))   (n(\m.f(\f.\x.s(\g.\h.h(g f))(\u.x)(\u.u))a m)(\f.\x.f x)))
string_lower(_, _).
function foo() {
  return bar();
}
USING: ;
IN: example

: foo ( -- x ) 4 ;

IN: math.margins

! Overriding math.margins definitions
: ± ( -- y ) 5 ;
USING: namespaces vocabs.loader prettyprint ;
IN: example

vocab-roots get .
Code
Diff
  • def foo(n):
        if n == 0:
            while True:
                yield 0
        else:
            for v in foo(n-1):
                yield v+1
    • USING: kernel math generators combinators.extras ;
    • IN: example
    • GEN: foo ( n -- gen )
    • [ [ 0 yield ] forever ]
    • [ 1 - foo [ [ next 1 + yield ] keep ] forever drop ] if-zero ;
    • def foo(n):
    • if n == 0:
    • while True:
    • yield 0
    • else:
    • for v in foo(n-1):
    • yield v+1

Builds a stack of depth generators, each incrementing a value starting at 0 by 1 before yielding. vals number of items are then generated. Expected time complexity should be O(depth * vals), however we find that depth = 10, vals = 1000 is very fast, depth = 100, vals = 100 is somewhat slow, and depth = 1000, vals = 10 is extremely slow (times out).

USING: kernel math generators combinators.extras ;
IN: example

GEN: foo ( n -- gen )
  [ [ 0 yield ] forever ]
  [ 1 - foo [ [ next 1 + yield ] keep ] forever drop ] if-zero ;

Simply loading sequences.extras adds ~5-6 seconds of runtime.

USING: sequences.extras ;
IN: example

: foo ( -- v ) 1 ;
USING: ;
IN: foo

: bla ( -- ) 3 ;
print("Solution code")
USING: kernel sequences qw ;
IN: foo

: x ( seq -- counts ) qw{ n e w s } [ [ = ] curry count ] with map ; inline

-1

Code
Diff
  • def f(s,p):s.c='YNeos'[(p=='')+sum(map(ord,p.lower()))%324>0::2]
    KumiteFoo=type('',(),{"__init__":f,"solution":lambda s:s.c})
    • def f(s,p):s.c='No'if(p=='')+sum(map(ord,p.lower()))%324else'Yes'
    • def f(s,p):s.c='YNeos'[(p=='')+sum(map(ord,p.lower()))%324>0::2]
    • KumiteFoo=type('',(),{"__init__":f,"solution":lambda s:s.c})
pattern1 = r"\d|\((?R)\)"
pattern2 = r"(.*)00(?1)"
Code
Diff
  • USING: kernel parser sequences quotations prettyprint fry ;
    QUALIFIED-WITH: tools.testest tt
    IN: testest.extras
    
    
    : wrap-it ( quot -- wrapped )
      '[ tt:it#{ _ dip tt:}# ] ;
      
    : wrap-describe ( quot -- wrapped )
      '[ tt:describe#{ _ dip tt:}# ] ;
    
    SYNTAX: it#{ \ tt:}# parse-until >quotation wrap-it append! ;
    SYNTAX: describe#{ \ tt:}# parse-until >quotation wrap-describe append! ;
    
    
    • USING: kernel parser sequences quotations prettyprint fry ;
    • QUALIFIED-WITH: tools.testest tt
    • IN: testest.extras
    • : wrap-it ( quot -- wrapped )
    • '[ tt:it#{ _ dip tt:}# ] ;
    • : wrap-describe ( quot -- wrapped )
    • '[ tt:describe#{ _ dip tt:}# ] ;
    • SYNTAX: it#{ \ tt:}# parse-until >quotation wrap-it suffix! \ call suffix! ;
    • SYNTAX: describe#{ \ tt:}# parse-until >quotation wrap-describe suffix! \ call suffix! ;
    • SYNTAX: it#{ \ tt:}# parse-until >quotation wrap-it append! ;
    • SYNTAX: describe#{ \ tt:}# parse-until >quotation wrap-describe append! ;
Loading more items...