Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement [//] and [||] operators. #1121

Closed
p6rt opened this issue Jul 6, 2009 · 7 comments
Closed

Implement [//] and [||] operators. #1121

p6rt opened this issue Jul 6, 2009 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 6, 2009

Migrated from rt.perl.org#67258 (status was 'resolved')

Searchable as RT67258$

@p6rt
Copy link
Author

p6rt commented Jul 6, 2009

From @kyleha

This is my crack at implementing these two operators. I'm looking for
feedback since I've never written for Rakudo before.

Thanks.

Kyle.

@p6rt
Copy link
Author

p6rt commented Jul 6, 2009

From @kyleha

0001--setting-Simple-implementation-of-operator.patch
From d83a888614383b80d30e5811f69ae974647628e0 Mon Sep 17 00:00:00 2001
From: Kyle Hasselbacher <kyle@livetext.com>
Date: Mon, 6 Jul 2009 09:17:21 -0500
Subject: [PATCH] [setting] Simple implementation of [||] operator

---
 src/setting/Operators.pm |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/setting/Operators.pm b/src/setting/Operators.pm
index 4aa6a8a..1608a45 100644
--- a/src/setting/Operators.pm
+++ b/src/setting/Operators.pm
@@ -60,4 +60,12 @@ sub prefix:<[//]>(@a) {
     return ();
 }
 
+sub prefix:<[||]>(@a) {
+    for @a -> $item {
+        $item || next;
+        return $item;
+    }
+    return ();
+}
+
 # vim: ft=perl6
-- 
1.6.0.4

@p6rt
Copy link
Author

p6rt commented Jul 6, 2009

From @kyleha

Here's the patch that didn't make it in the last email.

Kyle.

@p6rt
Copy link
Author

p6rt commented Jul 6, 2009

From @kyleha

0001-Simple-implementation-of-operator.patch
From 46d38aa631317f9af0a2d7d20ab0523b0684efd0 Mon Sep 17 00:00:00 2001
From: Kyle Hasselbacher <kyle@livetext.com>
Date: Mon, 6 Jul 2009 09:16:41 -0500
Subject: [PATCH] Simple implementation of [//] operator.

---
 src/setting/Operators.pm |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/setting/Operators.pm b/src/setting/Operators.pm
index 2460809..4aa6a8a 100644
--- a/src/setting/Operators.pm
+++ b/src/setting/Operators.pm
@@ -52,4 +52,12 @@ multi sub infix:<leg>($a, $b) {
     ~$a cmp ~$b;
 }
 
+sub prefix:<[//]>(@a) {
+    for @a -> $item {
+        $item // next;
+        return $item;
+    }
+    return ();
+}
+
 # vim: ft=perl6
-- 
1.6.0.4

@p6rt
Copy link
Author

p6rt commented Jul 24, 2009

From @moritz

Thanks for the patches, I've applied them with a few improvements​:

* squashed into one
* used slurpy params (so that it'll work with a single item, ([//] $x))
* registered the operators in src/parser/grammar-oper.pg so that they'll
get the right precedence (I don't know if the default precedence is the
right one, so this was just to be sure)

(commit dd5767c0cbfb4f1d70641e8499e21091be03729c)

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jul 24, 2009

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jul 24, 2009

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jul 24, 2009
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant