pyper 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86bd94959f7d92d97f3ae50b938bc4cc08bf2f3f
4
- data.tar.gz: 3a7d993030ddd5084ee0df32892fb5ddac5873cb
3
+ metadata.gz: ae702106bdc8ca11192dccacd049c668d5fd7309
4
+ data.tar.gz: 2a73f2e591932e5f58894200553f48bfb3b53901
5
5
  SHA512:
6
- metadata.gz: 747e5089a4095f008391f9215e0b467fc87b52561946116176b2b60f3c9fb9f60eb37affe191c5799fdfab659a8c02103e9699d30926fc8b33a48d8ac052ffc6
7
- data.tar.gz: 51282f2e4f2eec7c4e91e09c3f7023a3926adf175a5070b7593829aebea8eb2b385b4c69eecc4cfba89dd1fc8214232af18aeaacbf9961d072369435045f5713
6
+ metadata.gz: fe04b4c64f4f53e6431da543938e8f8c6a7cbfe8a4751589a0352a94a9a30d5eeeac702e073ab670458022cef72831ba95217375a3850938a67c433889a7e745
7
+ data.tar.gz: 8ca38172287630003f181528d898bb4d2583132ad67f76ff8e80530ff139c99d11d7e1cb03e60b52b66128dcd271d2f96d196a6583b2ea44726f221fbb571d4e
data/lib/pyper/version.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module Pyper
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
+ DEBUG = false
3
4
  end
data/lib/pyper.rb CHANGED
@@ -5,7 +5,6 @@ require "pyper/version"
5
5
  # Pyper is an extension of the Lispy car/cdr idea.
6
6
  #
7
7
  module Pyper
8
-
9
8
  # Everybody knows Lispy functions #car, #cdr. In Ruby, these functions
10
9
  # can be defined for example as:
11
10
  def car; first end # a: first
@@ -117,11 +116,11 @@ module Pyper
117
116
  mτ_string.gsub! /^alpha\nalpha\n/, "alpha\n" # workaround
118
117
  mτ_string.gsub! /^alpha\nalpha =/, "alpha =" # workaround
119
118
  mτ_string.gsub! /^alpha = alpha =/, 'alpha =' # workaround
120
- # puts mτ_string # DEBUG
119
+ puts mτ_string if Pyper::DEBUG
121
120
  self.class.module_eval( mτ_string )
122
121
  send( mτ_sym, *args, &block )
123
122
  }
124
- # puts "received msg #{mτ_sym}" # DEBUG
123
+ puts "received msg #{mτ_sym}" if Pyper::DEBUG
125
124
  case mτ_sym.to_s
126
125
  when /^τ(.+)τ$/ then pyperλ.( op: 1, ret: 1 )
127
126
  when /^π(.+)τ$/ then pyperλ.( op: 2, ret: 1 )
@@ -827,39 +826,39 @@ module Pyper
827
826
  #
828
827
  # Greek characters corresponding to the internal variable names of the
829
828
  # Pyper method are used to manipulate the argument source stack:
830
-
829
+
831
830
  # α pushes the primary pipeline (0) on the @argsrc stack:
832
831
  def α; @argsrc.alpha end
833
832
  # (Remark: Current pipe name is at the bottom of the @rr pipe stack)
834
-
833
+
835
834
  # β pushes the secondary pipeline (1) on the @argsrc stack:
836
835
  def β; @argsrc.beta end
837
836
  # (Remark: SUCC hash tells us what the other pipe is, based on the
838
837
  # current pipe name, seen on the *bottom* of the pipe stack @rr)
839
-
838
+
840
839
  # γ refers to the successor pipe (SUCC[@rr[0]]), but as there are only
841
840
  # two pipes, it is always the other pipe.
842
841
  def γ; @argsrc.var rSUCC( @rr[0] ) end
843
-
842
+
844
843
  # δ pushes the in-block pipeline delta on the @argsrc stack:
845
844
  def δ; @argsrc.delta end
846
-
845
+
847
846
  # ε, ζ push block arguments epsilon, resp. zeta on the @argsrc stack:
848
847
  def ε; @argsrc.epsilon end
849
848
  def ζ; @argsrc.zeta end
850
-
849
+
851
850
  # ψ and ω respectively refer to the penultimate and last args element:
852
851
  def ψ; @argsrc.psi end
853
852
  def ω; @argsrc.omega end
854
-
853
+
855
854
  # Lambda pushes onto the argument stack the default argument source, which
856
855
  # is the argument list indexed with write-time @arg_count index:
857
856
  def λ; @argsrc.args_counted end
858
-
857
+
859
858
  # Capital omega pushes onto the argument stack whole 'args' variable
860
859
  # (whole argument list), with 'shift' mode turned on by default:
861
860
  def Ω; @argsrc.args end
862
-
861
+
863
862
  # When inverted exclamation mark '¡' is used a prefix to the source
864
863
  # selector, then rather then being pushed on the @argsrc stack, the new
865
864
  # argument source replaces the topmost element of the stack. When the
@@ -876,20 +875,20 @@ module Pyper
876
875
  def ¡ω; @argsrc.omega! end
877
876
  def ¡λ; @argsrc.args_counted! end
878
877
  def ¡Ω; @argsrc.args! end
879
-
878
+
880
879
  # Small pi sets the 'dup' grab mode for the top @argsrc element:
881
- def π; @argsrc.shift! end
880
+ def π; @argsrc.dup! end
882
881
 
883
882
  # Small sigma sets the 'shift' grab mode for the top @argsrc element:
884
883
  def σ; @argsrc.shift! end
885
-
884
+
886
885
  # Small pi prefixed with inverted exclamation mark sets the 'ref'
887
886
  # (default) grab mode for the top@argsrc element (naturally, turning off
888
887
  # 'shift' or 'dup' mode).
889
888
  def ¡π; @argsrc.ref! end
890
889
  # Same for small sigma prefixed with inverted exclamation mark:
891
890
  alias :¡σ :¡π
892
-
891
+
893
892
  # Iota decrements the @arg_count index. If iota is used once, it causes
894
893
  # that same argument is used twice. If iota is used repeatedly, pointer
895
894
  # goes further back in the arg. ᴀ.
@@ -907,7 +906,16 @@ module Pyper
907
906
  def j; chain "join" end # nullary join
908
907
  # k:
909
908
  # l:
910
- def m; nullary_m_with_block "map" end # All-important #map method
909
+ # def m; nullary_m_with_block "map" end # All-important #map method
910
+
911
+ # '9' - [-1st] (ie. an array with only the last collection element)
912
+ def m
913
+ pipe_2_variable
914
+ start "if #@r.is_a? String then #@r = #@r.each_char end\n"
915
+ start
916
+ nullary_m_with_block "map"
917
+ end
918
+
911
919
  # n:
912
920
  # o: prefix character
913
921
  # p: ? recursive piper method, begin
@@ -919,6 +927,7 @@ module Pyper
919
927
  # Latin capital letters
920
928
  # ********************************************************************
921
929
  def A; pipe_2_variable; start "Array(#@r)" end # Array( pipe )
930
+ alias Α A # Greek Α, looks the same, different char
922
931
  def B; @take_block = true unless @take_block == :taken end # eat block
923
932
  def C; paren end # explicit parenthesize
924
933
  def D; exe "#@r = #@r.dup" end # self.dup
data/test/pyper_test.rb CHANGED
@@ -3,8 +3,8 @@
3
3
 
4
4
  require 'test/unit'
5
5
  require 'shoulda'
6
- # require_relative './../lib/pyper'
7
- require 'pyper'
6
+ require_relative './../lib/pyper'
7
+ # require 'pyper'
8
8
 
9
9
  include Pyper
10
10
 
@@ -105,5 +105,18 @@ class YPiperTest < ::Test::Unit::TestCase
105
105
  assert_equal ['x'], ['x'].τmß_mςτ
106
106
  assert_equal [[['y']]], [[[:y]]].τmmmςτ
107
107
  assert_equal [[:x, :y], [:v, :w]], [[?x, ?y], [?v, ?w]].τmmßτ
108
+
109
+ assert_equal [1, 1, 1], "abc".τm∅₁τ
110
+ require 'y_support/all'
111
+ @a = ["a", "b", "c"]
112
+ exp = [[["a"], ["b"], ["c"]],
113
+ [["a", "b"], ["c"]],
114
+ [["a"], ["b", "c"]],
115
+ [["a", "b", "c"]]]
116
+ rslt = ( 0...2**( @a.size - 1 ) )
117
+ .τm«_M﹪_mτ( "%0#{@a.size - 1}b", &[:τmᴇ⁇τ, ?0, ?+, ?,] )
118
+ .τm→ι←J_m﹪τ( '', "[@a[%s]]", [*0...@a.size] )
119
+ .τm→←_mτ( '[', ']', &method( :eval ) )
120
+ assert_equal exp.sort, rslt.sort
108
121
  end
109
122
  end # class
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-16 00:00:00.000000000 Z
11
+ date: 2013-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubyforge_project:
62
- rubygems_version: 2.0.0
62
+ rubygems_version: 2.0.3
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: 'Methods car, cdr, caar, cadr, cdar, caaar, caadr, ... are well known from