Guest User

Untitled

a guest
Apr 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.83 KB | None | 0 0
  1. [show] @?[~://]
  2. ?\ [show] @?[~:/^[^\n]*$/]   For a show that doesn`t allow newlines.
  3. [=] @?[~ ~:bool]
  4. [>] @?[~ ~:bool]
  5. [<] @?[~ ~:bool]
  6. [>=] @?[~ ~:bool]
  7. [<=] @?[~ ~:bool]
  8.  
  9. @true?[bool]:                          0 0 =
  10. @false?[bool]:                         true ~
  11.  
  12. @id?[~t:~t]:                           #x x
  13. @drop?[~:]:                            #_
  14. @drop2?[*2:]:                        #_#_
  15. @drop3?[*3:]:                      #_#_#_
  16. @dropn?[* int:]:                          list drop
  17. @dup?[~t:~t~t]:                        #x x x
  18. @dup2?[~s~t:(~s~t)*2]:               #x#y x y x y
  19. @dup3?[~r~s~t:(~r~s~t)*2]:         #x#y#z x y z x y z
  20. @dupn?[* int:*]:                          list [..][..] bi
  21. @over?[~s~t:~s~t~s]:                 #a#b a b a
  22. @over2?[~r~s~t:~r~s~t~r]:          #a#b#c a b c a
  23. @over3?[~r~s~t~u:~r~s~t~u~r]:    #a#b#c#d a b c d a
  24. @overn?[~t * int:~t * ~t]:                list [..][head] bi
  25. @swap?[~s~t:~t~s]:                   #a#b b a
  26. @rot?[~r~s~t:~s~t~r]:              #a#b#c b c a
  27.  
  28. @dip?[* ~t ~:* ~t]:                  #v#f f# v
  29. @dip2?[* ~s~t ~:* ~s~t]:           #v#w#f f# v w
  30. @dip3?[* ~r~s~t ~:* ~r~s~t]:     #v#w#x#f f# v w x
  31. @dipn?[* ~ int: *]:                  #f#n n list dip[f] ..
  32. @keep?[* ~t [* ~t:*]:* ~t]:          #v#f v f# v
  33. @bi?[~t [~t:*]*2:*]:               #v#f#g v f# v g#
  34. @tri?[~t [~t:*]*3:*]:            #v#f#g#h v f# v g# v h#
  35.  
  36. @curry?[~t [* ~t:*]:~]:              #x#f [x f#]
  37. @curry2?[~s~t [* ~s~t:*]:~]:       #x#y#f [x y f#]
  38. @curry3?[~r~s~t [* ~r~s~t:*]:~]: #x#y#z#f [x y z f#]
  39. @curryn?[* int:*]:                        times[curry]
  40. @compose?[~ ~:~]:                    #f#g [f# g#]
  41.  
  42. @_?#_?[* bool ~ ~:*]:                     ? #
  43. @if_t?[* bool ~:*]:                       [] ?#
  44. @if_f?[* bool ~:*]:                       [] swap ?#
  45. @?ifchain
  46.    @if?[bool ~:ifchain]: #c#f
  47.       ?ifchain{>$b[] >$sb[=b []=sb ic]} @ic ic
  48.       c if_t: .sb(f)
  49.    @elseif?[ifchain bool ~:ifchain]:#f if_t: .sb(f)
  50.    @else?[* ifchain ~:*]:#f .sb(f) .b#
  51.    @endif?[* ifchain:*]:.b#
  52. !?ifchain
  53.  
  54. @head?[{~t>}:~t]:                   #{x>} x
  55. @tail?[{>}:{>}]:                  #{_>xs} xs
  56. @top?[{<~t}:~t]:                    #{<x} x
  57. @under?[{<}:{<}]:                 #{xs<_} xs
  58. @pop?[{<~t}:{<} ~t]:              #{xs<x} xs x
  59. @popb?[{<~t}:~t {<}]:             #{xs<x} x xs
  60. @popn?[{<} int:{<} *]: #n n 0 > if_t: pop dip[n 1 - popn]
  61. @push?[{<} ~t:{<~t}]:               #xs#e {xs.. e}
  62. @pushb?[~t {<}:{<~t}]               #e#xs {xs.. e}
  63. @pushn?[{<} * int:{<}]:#n n 0 > if_t:dip[n 1 - pushn] push
  64. @append?[{*}{*}:{*}]:                #a#b {a.. b..}
  65. @prepend?[{*}{*}:{*}]:               #a#b {b.. a..}
  66.  
  67. @loop?[+:*]:                           #f f# f loop
  68. @while?[* [bool] ~:*]:               #c#f c# if_t: f# c f while
  69. @until?[* [bool] ~:*]:               #c#f c# if_f: f# c f until
  70. @dowhile?[* [bool]:*]:                 #f f# if_t: f dowhile
  71. @dountil?[* [bool]:*]:                 #f f# if_f: f dountil
  72. @fix?[+:*]:                            #f [f fix] f#
  73. @times?[* int ~:*]:#n#f n 0 > if_t: f# n 1 - times(f)
  74.  
  75. @map?[{>~t}[~t:*]:{>}]:                {#{x>xs}#f x f# map(xs,f)..}#`{#_#_}#
  76. @each?[{>~t}[~t:*]:*]:                 [#{x>xs}#f x f# each(xs,f)]#`[#_#_]#
  77. @filter?[{>~t}[~t:bool]:{>~t}]:        {#{x>xs}#p x p# if_t[x] xs p filter..}#`{#_#_}#
  78. @filterout?[{>~t}[~t:bool]:{>~t}]:     {#{x>xs}#p x p# if_f[x] xs p filterout..}#`{#_#_}#
  79. @takewhile?[{>~t}[~t:bool]:{>~t}]:     {#{x>xs}#p x p# if_t: x xs p takewhile..}#`{#_#_}#
  80. @takeuntil?[{>~t}[~t:bool]:{>~t}]:     {#{x>xs}#p x p# if_f: x xs p takewhile..}#`{#_#_}#
  81. @leavewhile?[{>~t}[~t:bool]:{>~t}]:    [#l{x>xs}#p x p# [xs p leavewhile][l]?#]#`[]#
  82. @leaveuntil?[{>~t}[~t:bool]:{>~t}]:    [#l{x>xs}#p x p# [l][xs p leaveuntil]?#]#`[]#
  83. @fold?[{>~s}~t[~t~s:~t]:~t]:           [#{x>xs}#e#f fold(xs, e x f#, f)]#`[#_#e#_ e]#
  84. @foldr?[{~s<}~t[~s~t:~t]:~t]:          [#{xs<x}#e#f foldr(xs, x e f# ,f)]#`[#_#e#_ e]#
  85. @reduce?[{>~t}[~t~t:~t]:~t]: #{x>xs}#f xs x f fold
  86. @reducer?[{~t<}[~t~t:~t]:~t]:       #f pop f foldr
  87. @scan?[{>~s}~t[~t~s:~t]:{>~t}]:        {#{x>xs}#e#f @r(e x f#) r scan(xs, r, f)..}#`{#_#_#_}#
  88. @scanr?[{~s<}~t[~s~t:~t]:{~t<}]:       {#{xs<x}#e#f @r(x e f#) scanr(xs, r, f).. r}#`{#_#_#_}#
  89. @spread?[{>~t}[~t~t:~t]:{>~t}]:        {#{x>xs}#f x scan(xs x f)..}#`{#_#_}#
  90. @spreadr?[{~t<}[~t~t:~t]:{~t<}]:       {#{xs<x}#f scanr(xs x f).. x}#`{#_#_}#
  91. @find?[{>~t}[~t:bool]:~t]:   #{x>xs}#p if(x p#)[x] else: xs p find
  92. @forall?[{>~t}[~t:bool]:bool]:         [#{x>xs}#p x p# [xs p forall][false]?#]#`[#_#_ true]#
  93. @exists?[{>~t}[~t:bool]:bool]:         [#{x>xs}#p x p# [true][xs p exists]?#]#`[#_#_ false]#
  94. @dowhilefound?[{>~t}[~t:* bool]:*]:    [#{x>xs}#p x p# if_t: xs p dowhilefound]#`[#_#_]#
  95. @dountilfound?[{>~t}[~t:* bool]:*]:    [#{x>xs}#p x p# if_f: xs p dountilfound]#`[#_#_]#
  96.  
  97. ?\ @list?[* int:{*}]:#n if(n 0 >)[#e n 1 - list e push] else{}
  98. @list?[* int:{*}]:   #n n 0 > [dip[n 1 - list] push] {} ?#
  99. @count?[int:{>int}]: #n {n loop[dup 1+]}
  100. @countd?[int:{>int}]:#n {n loop[dup 1-]}
  101. @iota?[:{>int}]:     #n count(0) below(n)
  102.  
  103. @box?[~t:{$~t}]:#v {r v $r}
  104. @array?[{~t*}:{$~t*}]:{#{v>vs} r v $r vs array..}#`{#_}#
  105.  
  106. @rev?[{>}:{<}]:               {#{x>xs} xs rev.. x}#`{#_}#
  107. @revb?[{<}:{>}]:              {#{xs<x} x xs rev..}#`{#_}#
  108. @cycle?[{>}:{>}]:          #l {l cycle.. l..}
  109. @cycleb?[{<}:{<}]:         #l {l.. l cycle..}
  110. @reps?[int {>}:{>}]:     #n#s {n times: s..}
  111. @string?[int ~t:{>~t}]:  #n#c {n times: c}
  112. @step?[{>}:{>}]:              {#l{x>}#n x (l n leave) n step..}#`{#l{x>}#_ x}#`{#_#_}#
  113.  
  114. @sum?[{>_+_}:_+_]:            reduce[+]
  115. @length?[{>}:int]:            map[#_ 1] sum
  116. @product?[{>_*_}:_*_]:        reduce[*]
  117. ?\ Exemplar @max?[[~ ~:bool]@_>_ {>_>_}:_>_]: reduce[#a#b a b > a b ?]
  118. @max?[{>_>_}:_>_]:            reduce[#a#b a b > a b ?]
  119. @min?[{>_<_}:_<_]:            reduce[#a#b a b < a b ?]
  120. @findmax?[{>~t}[~t:_>_]:_>_]: map max
  121. @findmin?[{>~t}[~t:_<_]:_<_]: map min
  122. @cat?[{>{*}}:{>}]:            map[..]
  123. @showcat?[{>_show_}://]:      map[.show..]
  124. @catlines?[{//*}://]:         map[.. '\n']
  125. @take?[{>} int:{>}]:       #n n 0 > {#{x>xs} x xs n 1 - take..} {#_} ?#
  126. @leave?[{>} int:{>}]:         times[tail]
  127. @topn?[{<} int:*]:         #n ift(n 0 >): pop dip[n 1 - topn]
  128. @undern?[{<} int:{<}]:        times[under]
  129. @upto?[{>_>_} int:{>_>_}]:       #n takeuntil[n >]
  130. @downto?[{>_<_} int:{>_<_}]:     #n takeuntil[n <]
  131. @upfrom?[{>_<_} int:{>_<_}]:     #n leavewhile[n <]
  132. @downfrom?[{>_>_} int:{>_>_}]:   #n leavewhile[n >]
  133. @above?[{>_>_} int:{>_>_}]:      #n takewhile[n >]
  134. @below?[{>_<_} int:{>_<_}]:      #n takewhile[n <]
  135. @fromabove?[{>_>_} int:{>_>_}]:  #n leaveuntil[n >]
  136. @frombelow?[{>_<_} int:{>_<_}]:  #n leaveuntil[n <]
  137.  
  138. @zip?[{>{>}}:{>{>}}]:         {#l l map[head], l map[tail] zip..}#`{#_}#
  139. @transpose?[{>{>}}:{>{>}}]:   filterout[{}=] {#l{_>} l map[head], l map[tail] transpose..}#`{#_}#
  140. @zipwith?[{>}* ~:{>}]:     #f zip map[.. f#]
  141.  
  142. @match?[_=_*2:_=_]: over = if_t: `
Add Comment
Please, Sign In to add comment