PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: plaid/sanctuary (js)
Issue: S.pluck?
This is really sheer laziness on my part but my code is littered with `R.map(S.get('key'), arr))`, it's an improvement on having to remember to do `R.reject(R.isNil, R.pluck('key', arr))` whenever I use `R.pluck` but it would be nice to have some sugar around such a common pattern.
Pull request description: Add S.pluck functionality
Resolves #20 

Patch:
diff --git a/index.js b/index.js
index 5337c41..90911db 100644
--- a/index.js
+++ b/index.js
@@ -277,6 +277,20 @@
     return Nothing();
   });
 
+  //. pluck :: String -> [{String: *}] -> [Maybe *]
+  //.
+  //. Takes a list of objects and plucks the value of the specified key
+  //. for each object in the list. Returns the value wrapped in a Just
+  //. if an object has the key and a Nothing if it does not.
+  //.
+  //. ```javascript
+  //. > pluck('a', [{a: 1, b: 2}, {a: 4, b: 5}, {b: 3, c: 7}])
+  //. [Just(1), Just(4), Nothing()]
+  //. ```
+  S.pluck = R.curry(function(key, xs) {
+    return R.map(get(key), xs);
+  });
+
   //  object  ////////////////////////////////////////////////////////////////
 
   //  get :: String -> Object -> Maybe *


Test patch:
diff --git a/test/index.js b/test/index.js
index 3c6c976..3284452 100644
--- a/test/index.js
+++ b/test/index.js
@@ -835,6 +835,34 @@ describe('list', function() {
 
   });
 
+  describe('pluck', function() {
+
+    it('returns array of Justs for found keys', function() {
+      var xs = [{a: 1, b: 3}, {a: 2, b: 4}, {a: 3, b: 5}];
+      var maybeXs = [S.Just(1), S.Just(2), S.Just(3)];
+      assert.deepEqual(S.pluck('a', xs), maybeXs);
+    });
+
+    it('returns array of Nothings for keys not found', function() {
+      var xs = [{a: 1, b: 3}, {a: 2, b: 4}, {a: 3, b: 5}];
+      var maybeXs = [S.Nothing(), S.Nothing(), S.Nothing()];
+      assert.deepEqual(S.pluck('c', xs), maybeXs);
+    });
+
+    it('returns Just(undefined) for defined key with no value', function() {
+      var xs = [{a: 1, b: 3}, {a: void 0, b: 4}, {a: 3, b: 5}];
+      var maybeXs = [S.Just(1), S.Just(void 0), S.Just(3)];
+      assert.deepEqual(S.pluck('a', xs), maybeXs);
+    });
+
+    it('returns an array of Maybes for various values', function() {
+      var xs = [{a: 1}, {a: void 0}, {a: 4}, {b: 1}];
+      var maybeXs = [S.Just(1), S.Just(void 0), S.Just(4), S.Nothing()];
+      assert.deepEqual(S.pluck('a', xs), maybeXs);
+    });
+
+  });
+
 });
 
 describe('object', function() {
Repository: vaskoz/dailycodingproblem-go (go)
Issue: Day 68
Good morning! Here's your coding interview problem for today.

This problem was asked by Google.

On our special chessboard, two bishops attack each other if they share the same diagonal. This includes bishops that have another bishop located between them, i.e. bishops can attack through pieces.

You are given N bishops, represented as (row, column) tuples on a M by M chessboard. Write a function to count the number of pairs of bishops that attack each other. The ordering of the pair doesn't matter: (1, 2) is considered the same as (2, 1).

For example, given M = 5 and the list of bishops:
```
(0, 0)
(1, 2)
(2, 2)
(4, 0)
```
The board would look like this:
```
[b 0 0 0 0]
[0 0 b 0 0]
[0 0 b 0 0]
[0 0 0 0 0]
[b 0 0 0 0]
```
You should return 2, since bishops 1 and 3 attack each other, as well as bishops 3 and 4.
Pull request description: Day68
Resolves #145 .

Patch:
diff --git a/README.md b/README.md
index 42bc6d4..a723b30 100644
--- a/README.md
+++ b/README.md
@@ -77,3 +77,4 @@ problems from
 * [Day 65](https://github.com/vaskoz/dailycodingproblem-go/issues/139)
 * [Day 66](https://github.com/vaskoz/dailycodingproblem-go/issues/141)
 * [Day 67](https://github.com/vaskoz/dailycodingproblem-go/issues/143)
+* [Day 68](https://github.com/vaskoz/dailycodingproblem-go/issues/145)
diff --git a/day68/problem.go b/day68/problem.go
new file mode 100644
index 0000000..0b7bc22
--- /dev/null
+++ b/day68/problem.go
@@ -0,0 +1,26 @@
+package day68
+
+// BoardPosition represents a row and column on a square chessboard.
+type BoardPosition struct {
+	Row, Col int
+}
+
+// CountAttackingBishopPairs returns the count of the number of attacking
+// pairs of Bishops.
+// M is the dimension of the chessboard. M x M
+// Runtime is O(N^2) where N is the number of bishops.
+func CountAttackingBishopPairs(bishops []BoardPosition, M int) int {
+	count := 0
+	for i := 0; i < len(bishops)-1; i++ {
+		first := bishops[i]
+		for j := i + 1; j < len(bishops); j++ {
+			second := bishops[j]
+			rowdiff := second.Row - first.Row
+			coldiff := second.Col - first.Col
+			if rowdiff == coldiff || rowdiff == -coldiff {
+				count++
+			}
+		}
+	}
+	return count
+}


Test patch:
diff --git a/day68/problem_test.go b/day68/problem_test.go
new file mode 100644
index 0000000..e4dcbda
--- /dev/null
+++ b/day68/problem_test.go
@@ -0,0 +1,28 @@
+package day68
+
+import "testing"
+
+var testcases = []struct {
+	bishops  []BoardPosition
+	m        int
+	expected int
+}{
+	{[]BoardPosition{{0, 0}, {1, 2}, {2, 2}, {4, 0}}, 5, 2},
+}
+
+func TestCountAttackingBishopPairs(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := CountAttackingBishopPairs(tc.bishops, tc.m); result != tc.expected {
+			t.Errorf("Expected %v got %v", tc.expected, result)
+		}
+	}
+}
+
+func BenchmarkCountAttackingBishopPairs(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			CountAttackingBishopPairs(tc.bishops, tc.m)
+		}
+	}
+}
Repository: ACloudGuru/serverless-plugin-aws-alerts (js)
Issue: Alarm won't trigger even alarm was created successfully
Currently, alarm has invalid dimension. so alarm won't trigger even alarm was created successfully.

This is our example serverless.yml:
```yml
# (truncated)

plugins:
  - serverless-plugin-aws-alerts
functions:
  hello:
    handler: handlers.hello
    alarms:
      - functionErrors

custom:
  alerts:
    definitions:
      functionErrors:
        namespace: 'AWS/Lambda'
        metric: Errors
        threshold: 1
        statistic: Minimum
        period: 600
        evaluationPeriods: 1
        comparisonOperator: GreaterThanThreshold

# (truncated)
```


Generated CloudFormation content:
```json
{
  "Resources": {
    "ValidateFunctionErrorsAlarm": {
      "Type": "AWS::CloudWatch::Alarm",
      "Properties": {
        "Namespace": "AWS/Lambda",
        "MetricName": "Errors",
        "Threshold": 1,
        "Statistic": "Minimum",
        "Period": 600,
        "EvaluationPeriods": 1,
        "ComparisonOperator": "GreaterThanThreshold",
        "OKActions": [],
        "AlarmActions": [],
        "InsufficientDataActions": [],
        "Dimensions": [
          {
            "Name": "HelloLambdaFunctionName",
            "Value": {
              "Ref": "HelloLambdaFunction"
            }
          }
        ]
      }
    }
  }
}
```

I think value of `Dimensions[0].Name` should be use 'FunctionName', not `${ref}Name`.
Pull request description: fix alarm won’t triggered. closes #12
Closes #12.


Patch:
diff --git a/src/index.js b/src/index.js
index a07737d..446b56b 100644
--- a/src/index.js
+++ b/src/index.js
@@ -99,7 +99,7 @@ class Plugin {
 		} else {
 			const dimensions = _.map(functionRefs, (ref) => {
 				return {
-					Name: `${ref}Name`,
+					Name: 'FunctionName',
 					Value: {
 						Ref: ref,
 					},


Test patch:
diff --git a/src/index.test.js b/src/index.test.js
index 12898d8..b5066e6 100644
--- a/src/index.test.js
+++ b/src/index.test.js
@@ -341,7 +341,7 @@ describe('#index', function () {
 						OKActions: [],
 						InsufficientDataActions: [],
 						Dimensions: [{
-							Name: 'FooLambdaFunctionName',
+							Name: 'FunctionName',
 							Value: { Ref: 'FooLambdaFunction' },
 						}]
 					}
@@ -404,7 +404,7 @@ describe('#index', function () {
 						OKActions: [],
 						InsufficientDataActions: [],
 						Dimensions: [{
-							Name: 'FooLambdaFunctionName',
+							Name: 'FunctionName',
 							Value: { Ref: 'FooLambdaFunction' },
 						}]
 					}
Repository: DestinyItemManager/DIM (ts)
Issue: suggester considers incomplete range filters to be complete
once you add the math operator here,
suggester considers the previous filter complete enough that it starts suggesting fresh new filters if you type enough to trigger suggestions
`season:` doesn't trigger this,
`season:<` or `season:=` etc triggers this

![image](https://user-images.githubusercontent.com/68782081/107032129-29c57c00-6768-11eb-852a-1f3a268b1bd9.png)

Pull request description: Fix autocompletion considering rangeoverload filters complete too early
Would be cool to actually complete the term here but that'd have to happen in the autocompleter because I don't want to blow up filters help again.

Fixes #6482.

Patch:
diff --git a/src/app/search/autocomplete.ts b/src/app/search/autocomplete.ts
index 0dae9fb9f..b1af6b694 100644
--- a/src/app/search/autocomplete.ts
+++ b/src/app/search/autocomplete.ts
@@ -168,7 +168,7 @@ export function filterSortRecentSearches(query: string, recentSearches: Search[]
 const caretEndRegex = /([\s)]|$)/;
 
 // most times, insist on at least 3 typed characters, but for #, start suggesting immediately
-const lastWordRegex = /(\b[\w:"']{3,}|#\w*)$/;
+const lastWordRegex = /(\b[\w:"'<=>]{3,}|#\w*)$/;
 // matches a string that seems to end with a closing, not opening, quote
 const closingQuoteRegex = /\w["']$/;
 


Test patch:
diff --git a/src/app/search/__snapshots__/autocomplete.test.ts.snap b/src/app/search/__snapshots__/autocomplete.test.ts.snap
index 51e6f7698..d00b2a235 100644
--- a/src/app/search/__snapshots__/autocomplete.test.ts.snap
+++ b/src/app/search/__snapshots__/autocomplete.test.ts.snap
@@ -51,6 +51,8 @@ Array [
 ]
 `;
 
+exports[`autocompleteTermSuggestions autocomplete within query for |season:>outl| with caret at position 12 1`] = `Array []`;
+
 exports[`filterComplete autocomplete terms for |is:b| 1`] = `
 Array [
   "is:bow",
diff --git a/src/app/search/autocomplete.test.ts b/src/app/search/autocomplete.test.ts
index 4f77f7a78..befcf8cc3 100644
--- a/src/app/search/autocomplete.test.ts
+++ b/src/app/search/autocomplete.test.ts
@@ -14,6 +14,7 @@ describe('autocompleteTermSuggestions', () => {
     ['is:haspower is:b', 16],
     ['(is:blue jun)', 11],
     ['is:bow is:void', 11],
+    ['season:>outl', 12],
   ];
 
   test.each(cases)(
Repository: lesshint/lesshint (js)
Issue: Come with a JSON reporter?
Seems like a pretty useful reporter for external tools; is there much problem in adding one by default?

```javascript
/*eslint no-console: 0*/

'use strict';

module.exports = {
    name: 'json',
    report: function report (results) {
        results.forEach(function (result) {
            console.log(JSON.stringify(result));
        });
    }
};
```
Pull request description: Added a JSON reporter
Logs stringified results as JSON.

Fixes #280.

Patch:
diff --git a/lib/reporters/json.js b/lib/reporters/json.js
new file mode 100644
index 0000000..2c3ac45
--- /dev/null
+++ b/lib/reporters/json.js
@@ -0,0 +1,10 @@
+/*eslint no-console: 0*/
+
+'use strict';
+
+module.exports = {
+    name: 'json',
+    report: function report (results) {
+        console.log(JSON.stringify(results));
+    }
+};


Test patch:
diff --git a/test/specs/reporters/json.js b/test/specs/reporters/json.js
new file mode 100644
index 0000000..732b3ae
--- /dev/null
+++ b/test/specs/reporters/json.js
@@ -0,0 +1,43 @@
+/*eslint no-console: 0*/
+
+'use strict';
+
+var expect = require('chai').expect;
+var rewire = require('rewire');
+var sinon = require('sinon');
+
+describe('reporter:json', function () {
+    var reporter = rewire('../../../lib/reporters/json.js');
+
+    beforeEach(function () {
+        sinon.stub(process.stdout, 'write');
+    });
+
+    afterEach(function () {
+        if (process.stdout.write.restore) {
+            process.stdout.write.restore();
+        }
+    });
+
+    it('should print an error completely', function () {
+        var message;
+        var errors = [{
+            line: 1,
+            file: 'file.less',
+            linter: 'spaceBeforeBrace',
+            message: 'Opening curly brace should be preceded by one space.',
+            severity: 'error',
+            source: '.foo{ color: red; }'
+        }];
+
+        sinon.spy(console, 'log');
+
+        reporter.report(errors);
+
+        message = console.log.getCall(0).args[0];
+
+        expect(message).to.equal(JSON.stringify(errors));
+
+        console.log.restore();
+    });
+});
Repository: effekt-lang/effekt (scala)
Issue: JS backend: Array.toList drops first element
Executing `.toList` on an array drops the first element.

## Example
For the program:
```effekt
import mutable/array

def main() = {
  val array = arrayFromList([1,2,3]);
  println(array.toList)
}
```
we get the output:
```
Cons(2, Cons(3, Nil()))
```
Pull request description: Fixes #319.

Patch:
diff --git a/examples/pos/issue319.check b/examples/pos/issue319.check
new file mode 100644
index 000000000..385e54d12
--- /dev/null
+++ b/examples/pos/issue319.check
@@ -0,0 +1,1 @@
+Cons(1, Cons(2, Cons(3, Nil())))
diff --git a/examples/pos/issue319.effekt b/examples/pos/issue319.effekt
new file mode 100644
index 000000000..43647ed97
--- /dev/null
+++ b/examples/pos/issue319.effekt
@@ -0,0 +1,6 @@
+import mutable/array
+
+def main() = {
+  val array = arrayFromList([1,2,3]);
+  println(array.toList)
+}
diff --git a/libraries/js/mutable/array.effekt b/libraries/js/mutable/array.effekt
index cc4d47981..0f3443d84 100644
--- a/libraries/js/mutable/array.effekt
+++ b/libraries/js/mutable/array.effekt
@@ -52,7 +52,7 @@ extern pure def copy[T](arr: Array[T]): Array[T] =
 def toList[T](arr: Array[T]): List[T] = {
   var i = arr.size - 1;
   var l = Nil[T]()
-  while (i > 0) {
+  while (i >= 0) {
     l = Cons(unsafeGet(arr, i), l)
     i = i - 1
   }


Test patch:
diff --git a/effekt/jvm/src/test/scala/effekt/ChezSchemeTests.scala b/effekt/jvm/src/test/scala/effekt/ChezSchemeTests.scala
index b6c1dc54b..e1a3c291d 100644
--- a/effekt/jvm/src/test/scala/effekt/ChezSchemeTests.scala
+++ b/effekt/jvm/src/test/scala/effekt/ChezSchemeTests.scala
@@ -23,6 +23,7 @@ abstract class ChezSchemeTests extends EffektTests {
     examplesDir / "ml",
 
     examplesDir / "pos" / "arrays.effekt",
+    examplesDir / "pos" / "issue319.effekt",
     examplesDir / "pos" / "maps.effekt",
 
     // bidirectional effects are not yet supported in our Chez backend
diff --git a/effekt/jvm/src/test/scala/effekt/MLTests.scala b/effekt/jvm/src/test/scala/effekt/MLTests.scala
index 1175b990b..79836dc0c 100644
--- a/effekt/jvm/src/test/scala/effekt/MLTests.scala
+++ b/effekt/jvm/src/test/scala/effekt/MLTests.scala
@@ -92,6 +92,7 @@ class MLTests extends EffektTests {
 
     // array api
     examplesDir / "pos" / "raytracer.effekt",
+    examplesDir / "pos" / "issue319.effekt",
 
     // async
     examplesDir / "pos" / "io" / "async_file_io.effekt",