Project

General

Profile

Feature #10068

[PATCH] Implement monadic operator for Vector

Added by gogotanaka (Kazuki Tanaka) almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-core:63847]

Description

Before

v = Vector[1, 2, 3]

 + v
=> NoMethodError: undefined method `+@' for Vector[1, 2, 3]:Vector

 - v
=> NoMethodError: undefined method `-@' for Vector[1, 2, 3]:Vector

After

v = Vector[1, 2, 3]

 + v
=> Vector[1, 2, 3]

 - v
=> Vector[-1, -2, -3]
implement_uplus_for_vector.patch (842 Bytes) implement_uplus_for_vector.patch gogotanaka (Kazuki Tanaka), 07/19/2014 01:56 AM
implement_negate_for_vector.patch (1.25 KB) implement_negate_for_vector.patch gogotanaka (Kazuki Tanaka), 07/19/2014 01:56 AM

Related issues

Related to Ruby trunk - Feature #10069: [PATCH] Implement monadic operator for MatrixClosed2014-07-19

Associated revisions

Revision a2ae7bcc
Added by marcandre (Marc-Andre Lafortune) over 3 years ago

  • lib/matrix.rb: Add @- and @+ for Matrix and Vector. patch by gogo tanaka [#10068] [#10069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 47840
Added by marcandre (Marc-Andre Lafortune) over 3 years ago

  • lib/matrix.rb: Add @- and @+ for Matrix and Vector. patch by gogo tanaka [#10068] [#10069]

Revision 47840
Added by marcandre (Marc-Andre Lafortune) over 3 years ago

  • lib/matrix.rb: Add @- and @+ for Matrix and Vector. patch by gogo tanaka [#10068] [#10069]

Revision 47840
Added by marcandre (Marc-Andre Lafortune) over 3 years ago

  • lib/matrix.rb: Add @- and @+ for Matrix and Vector. patch by gogo tanaka [#10068] [#10069]

Revision 47840
Added by marcandre (Marc-Andre Lafortune) over 3 years ago

  • lib/matrix.rb: Add @- and @+ for Matrix and Vector. patch by gogo tanaka [#10068] [#10069]

Revision 47840
Added by marcandre (Marc-Andre Lafortune) over 3 years ago

  • lib/matrix.rb: Add @- and @+ for Matrix and Vector. patch by gogo tanaka [#10068] [#10069]

History

#1 [ruby-core:63849] Updated by gogotanaka (Kazuki Tanaka) almost 4 years ago

I'm sorry my report looks ugly... I fix it. ↓

Before

v = Vector[1, 2, 3]

+ v
=> NoMethodError: undefined method `+@' for Vector[1, 2, 3]:Vector

- v
=> NoMethodError: undefined method `-@' for Vector[1, 2, 3]:Vector

After

v = Vector[1, 2, 3]

+ v
=> Vector[1, 2, 3]

- v
=> Vector[-1, -2, -3]

#2 [ruby-core:63868] Updated by matz (Yukihiro Matsumoto) almost 4 years ago

I am not sure the term monadic is a proper one, but I like the idea.

Matz.

#3 [ruby-core:63869] Updated by matz (Yukihiro Matsumoto) almost 4 years ago

  • Related to Feature #10069: [PATCH] Implement monadic operator for Matrix added

#4 [ruby-core:63903] Updated by hsbt (Hiroshi SHIBATA) almost 4 years ago

  • Category set to lib
  • Status changed from Open to Assigned
  • Assignee set to marcandre (Marc-Andre Lafortune)
  • Target version set to 2.2.0

#5 [ruby-core:65494] Updated by marcandre (Marc-Andre Lafortune) over 3 years ago

  • Status changed from Assigned to Closed

Done.

Thanks for catching this omission, and for the patch.

Also available in: Atom PDF