{"action":"created","issue":{"url":"https://api.github.com/repos/josdejong/mathjs/issues/368","labels_url":"https://api.github.com/repos/josdejong/mathjs/issues/368/labels{/name}","comments_url":"https://api.github.com/repos/josdejong/mathjs/issues/368/comments","events_url":"https://api.github.com/repos/josdejong/mathjs/issues/368/events","html_url":"https://github.com/josdejong/mathjs/pull/368","id":76208048,"number":368,"title":"Extend Index implementation to support set of values","user":{"login":"rjbaucells","id":1074987,"avatar_url":"https://avatars.githubusercontent.com/u/1074987?v=3","gravatar_id":"","url":"https://api.github.com/users/rjbaucells","html_url":"https://github.com/rjbaucells","followers_url":"https://api.github.com/users/rjbaucells/followers","following_url":"https://api.github.com/users/rjbaucells/following{/other_user}","gists_url":"https://api.github.com/users/rjbaucells/gists{/gist_id}","starred_url":"https://api.github.com/users/rjbaucells/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjbaucells/subscriptions","organizations_url":"https://api.github.com/users/rjbaucells/orgs","repos_url":"https://api.github.com/users/rjbaucells/repos","events_url":"https://api.github.com/users/rjbaucells/events{/privacy}","received_events_url":"https://api.github.com/users/rjbaucells/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-14T02:59:01Z","updated_at":"2015-05-16T14:30:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/josdejong/mathjs/pulls/368","html_url":"https://github.com/josdejong/mathjs/pull/368","diff_url":"https://github.com/josdejong/mathjs/pull/368.diff","patch_url":"https://github.com/josdejong/mathjs/pull/368.patch"},"body":"This is the pull request that implements the solution proposed in #367 \r\n\r\nChanges:\r\n\r\n- Allows the expression parser to use a set of values as a Matrix index\r\n````\r\nA = [...]; // MxN matrix\r\np = [1, 2, 3];\r\nB = A[p,:]; // Rows 1, 2 and 3 of A\r\nC = A[:,p]; // Columns 1, 2 and 3 of A\r\n````\r\n\r\n- Allows the JavaScript code to use an array as a possible dimension value for an Index (breaking change!)\r\n\r\n````\r\nA = [[...]]; // MxN matrix\r\np = [0, 1, 2];\r\nB = A.subset(math.index(p, p)); // submatrix with rows 1, 2, 3 and columns 1, 2, 3 of A\r\n````\r\n\r\n- Renamed the `Index.prototype.range()` operation to `Index.prototype.dimension()` since now Index supports `Range` and `Set` instances.\r\n\r\n- Introduced the `Set` type to represent the set of values for an Index dimension. `Set` type contains the same operations as `Range` so consuming code should not change.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/josdejong/mathjs/issues/comments/102632650","html_url":"https://github.com/josdejong/mathjs/pull/368#issuecomment-102632650","issue_url":"https://api.github.com/repos/josdejong/mathjs/issues/368","id":102632650,"user":{"login":"rjbaucells","id":1074987,"avatar_url":"https://avatars.githubusercontent.com/u/1074987?v=3","gravatar_id":"","url":"https://api.github.com/users/rjbaucells","html_url":"https://github.com/rjbaucells","followers_url":"https://api.github.com/users/rjbaucells/followers","following_url":"https://api.github.com/users/rjbaucells/following{/other_user}","gists_url":"https://api.github.com/users/rjbaucells/gists{/gist_id}","starred_url":"https://api.github.com/users/rjbaucells/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjbaucells/subscriptions","organizations_url":"https://api.github.com/users/rjbaucells/orgs","repos_url":"https://api.github.com/users/rjbaucells/repos","events_url":"https://api.github.com/users/rjbaucells/events{/privacy}","received_events_url":"https://api.github.com/users/rjbaucells/received_events","type":"User","site_admin":false},"created_at":"2015-05-16T14:30:51Z","updated_at":"2015-05-16T14:30:51Z","body":"I did not go with the Matrix because I wanted to make the `Set` immutable, the same as the `Range` and `Index`. Matrix provides operations that modified the data been stored (`set()`, `subset()`, `resize()`). I did not liked the idea of having an Index dimension changing after creation while the others are fixed (thing that I think is the way it should be).\r\n\r\nI will work on implementing the syntax you proposed next week, still we need to decide if having a mutable Index dimension is correct or not.\r\n\r\nLet me know what you think..."}}