notation 0.1.0

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.
data/CHANGES ADDED
@@ -0,0 +1,2 @@
1
+ = 0.1.0 - 13-Dec-2009
2
+ * Initial release
@@ -0,0 +1,7 @@
1
+ * CHANGES
2
+ * MANIFEST
3
+ * README
4
+ * Rakefile
5
+ * notation.gemspec
6
+ * lib/notation.rb
7
+ * test/test_notation.rb
data/README ADDED
@@ -0,0 +1,21 @@
1
+ = Description
2
+ Unicode methods for Ruby.
3
+
4
+ = Installation
5
+ gem install notation
6
+
7
+ = Synopsis
8
+ # Run with -Ku
9
+ require 'notation'
10
+
11
+ λ { puts "hello" } # => "Hello"
12
+ ∑ [1,2,3] # => 6
13
+ √ 49 # => 7.0
14
+
15
+ = Author's Notes
16
+ This library was inspired by the programming language Fortress, an offshoot
17
+ of Fortran, created by Sun. Fortress supports unicode operators baked into
18
+ the language.
19
+
20
+ = Author
21
+ Daniel Berger
@@ -0,0 +1,26 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ include Config
4
+
5
+ desc "Install the notation library"
6
+ task :install_lib do
7
+ cp 'lib/notation.rb', CONFIG['sitelibdir'], :verbose => true
8
+ end
9
+
10
+ desc 'Build the notation gem'
11
+ task :gem do
12
+ spec = eval(IO.read('notation.gemspec'))
13
+ Gem::Builder.new(spec).build
14
+ end
15
+
16
+ desc 'Install the notation library as a gem'
17
+ task :install_gem => [:gem] do
18
+ file = Dir["*.gem"].first
19
+ sh "gem install #{file}"
20
+ end
21
+
22
+ Rake::TestTask.new do |t|
23
+ t.warning = true
24
+ t.verbose = true
25
+ t.ruby_opts << '-Ku'
26
+ end
@@ -0,0 +1,33 @@
1
+ # Run with -Ku
2
+
3
+ module Kernel
4
+ # Version of the notation library
5
+ NOTATION_VERSION = '0.1.0'
6
+
7
+ # Make lambda a true lambda
8
+ #
9
+ # Example:
10
+ # λ { puts 'Hello' }.call => 'Hello'
11
+ #
12
+ alias λ proc
13
+
14
+ # Sigma, i.e. the sum of all elements.
15
+ #
16
+ # Example:
17
+ # ∑ [1,2,3] => 6
18
+ #
19
+ def ∑(*args)
20
+ sum = 0
21
+ args.each{ |e| sum += e }
22
+ sum
23
+ end
24
+
25
+ # Square root
26
+ #
27
+ # Example:
28
+ # √ 49 => 7.0
29
+ #
30
+ def √(root)
31
+ Math.sqrt(root)
32
+ end
33
+ end
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'notation'
5
+ gem.version = '0.1.0'
6
+ gem.author = 'Daniel J. Berger'
7
+ gem.email = 'djberg96@gmail.com'
8
+ gem.homepage = 'http://www.rubyforge.org/projects/shards'
9
+ gem.summary = 'Unicode symbols that can be used as methods.'
10
+ gem.test_file = 'test/test_notation.rb'
11
+ gem.has_rdoc = true
12
+ gem.files = Dir['**/*'].delete_if{ |item| item.include?('git') }
13
+
14
+ gem.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
15
+ gem.rubyforge_project = 'shards'
16
+
17
+ gem.description = <<-EOF
18
+ The notation library provides unicode symbols that you can use as
19
+ methods instead of using standard method names.
20
+ EOF
21
+ end
@@ -0,0 +1,28 @@
1
+ #######################################################################
2
+ # test_notation.rb
3
+ #
4
+ # Test case for the notation library. This should be run via the
5
+ # 'rake test' task.
6
+ #######################################################################
7
+ require 'test/unit'
8
+ require 'notation'
9
+
10
+ class TC_Notation < Test::Unit::TestCase
11
+ def test_version
12
+ assert_equal('0.1.0', NOTATION_VERSION)
13
+ end
14
+
15
+ def test_sigma
16
+ assert_respond_to(Kernel, :∑)
17
+ assert_equal(6, ∑(1,2,3))
18
+ end
19
+
20
+ def test_square_root
21
+ assert_respond_to(Kernel, :√)
22
+ assert_equal(7.0, √(49))
23
+ end
24
+
25
+ def test_lambda
26
+ assert_equal('hello', λ { 'hello' }.call)
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: notation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel J. Berger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-13 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: " The notation library provides unicode symbols that you can use as\n methods instead of using standard method names.\n"
17
+ email: djberg96@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - CHANGES
24
+ - README
25
+ - MANIFEST
26
+ files:
27
+ - CHANGES
28
+ - lib/notation.rb
29
+ - MANIFEST
30
+ - notation.gemspec
31
+ - Rakefile
32
+ - README
33
+ - test/test_notation.rb
34
+ has_rdoc: true
35
+ homepage: http://www.rubyforge.org/projects/shards
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project: shards
58
+ rubygems_version: 1.3.5
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Unicode symbols that can be used as methods.
62
+ test_files:
63
+ - test/test_notation.rb