Project

General

Profile

Feature #10068

[PATCH] Implement monadic operator for Vector

Added by gogo tanaka almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
[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 Magnifier (842 Bytes) gogo tanaka, 07/19/2014 01:56 AM

implement_negate_for_vector.patch Magnifier (1.25 KB) gogo tanaka, 07/19/2014 01:56 AM


Related issues

Related to Ruby trunk - Feature #10069: [PATCH] Implement monadic operator for Matrix Closed 07/19/2014

Associated revisions

Revision 47840
Added by Marc-Andre Lafortune over 1 year ago

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

Revision 47840
Added by Marc-Andre Lafortune over 1 year ago

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

Revision 47840
Added by Marc-Andre Lafortune over 1 year ago

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

History

#1 [ruby-core:63849] Updated by gogo tanaka almost 2 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 Yukihiro Matsumoto almost 2 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 Yukihiro Matsumoto almost 2 years ago

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

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

  • Assignee set to Marc-Andre Lafortune
  • Target version set to current: 2.2.0
  • Category set to lib
  • Status changed from Open to Assigned

#5 [ruby-core:65494] Updated by Marc-Andre Lafortune over 1 year ago

  • Status changed from Assigned to Closed

Done.

Thanks for catching this omission, and for the patch.

#6 [ruby-core:65497] Updated by gogo tanaka over 1 year ago

Thank you, too.

Also available in: Atom PDF