{"action":"created","comment":{"url":"https://api.github.com/repos/socraticorg/mathjs/pulls/comments/83658818","pull_request_review_id":4477495,"id":83658818,"diff_hunk":"@@ -0,0 +1,104 @@\n+'use strict';\n+\n+const NodeCreator = require('./NodeCreator');\n+const NodeType = require('./NodeType');\n+const PolynomialTermNode = require('./PolynomialTermNode');\n+\n+const Symbols = {};\n+\n+// returns the set of all the symbols in an equation\n+Symbols.getSymbolsInEquation = function(equation) {\n+  const leftSymbols = Symbols.getSymbolsInExpression(equation.leftNode);\n+  const rightSymbols = Symbols.getSymbolsInExpression(equation.rightNode);\n+  const symbols = new Set(...leftSymbols, ...rightSymbols);\n+  return symbols;\n+}\n+\n+// return the set of symbols in the expression tree\n+Symbols.getSymbolsInExpression = function(expression) {\n+  const symbolNodes = expression.filter(node => node.isSymbolNode); // all the symbol nodes\n+  const symbols = symbolNodes.map(node => node.name); // all the symbol nodes' names\n+  const symbolSet = new Set(symbols); // to get rid of duplicates\n+  return symbolSet;\n+}\n+\n+// Iterates through a node and returns the polynomial term with the symbol name\n+Symbols.getFirstSymbolTerm = function(node, symbolName) {\n+  let symbolTerm = Symbols.getSymbolTerm(node, symbolName);\n+  if (symbolTerm) {\n+    return symbolTerm;\n+  }\n+  else if (NodeType.isOperator(node)) {\n+    for (let i = 0; i < node.args.length; i++) {\n+      const child = node.args[i];\n+      const symbolTerm = Symbols.getSymbolTerm(child, symbolName);\n+      if (symbolTerm) {\n+        return symbolTerm;\n+      }\n+    }\n+  }\n+\n+  return null;\n+}\n+\n+// Iterates through a node and returns the last term that does not have the\n+// symbolName including other polynomial terms, and constants or constant fractions\n+Symbols.getLastNonSymbolTerm = function(node, symbolName) {\n+  const symbolCoefficient = Symbols.getSymbolCoefficient(node, symbolName);\n+  if (symbolCoefficient) {\n+    return symbolCoefficient;\n+  }\n+  else if (NodeType.isOperator(node)) {\n+    for (let i = node.args.length - 1; i >= 0 ; i--) {\n+      const child = node.args[i];\n+      const nonSymbolTerm = Symbols.getNonSymbolTerm(child, symbolName);\n+      if (nonSymbolTerm) {\n+        return nonSymbolTerm;\n+      }\n+    }\n+  }\n+\n+  return null;\n+}\n+\n+// Returns the polynomial term in the node the given symbolName\n+Symbols.getSymbolTerm = function(node, symbolName) {\n+  if (PolynomialTermNode.isPolynomialTerm(node)) {\n+    const polyTerm = new PolynomialTermNode(node);\n+    if (polyTerm.symbolName() === symbolName) {\n+      return polyTerm.rootNode();","path":"lib/expression/step-solver/Symbols.js","position":69,"original_position":69,"commit_id":"d5756d95b060cfb5fefbe3f63d9cb5d627652e4a","original_commit_id":"d5756d95b060cfb5fefbe3f63d9cb5d627652e4a","user":{"login":"evykassirer","id":5634097,"avatar_url":"https://avatars.githubusercontent.com/u/5634097?v=3","gravatar_id":"","url":"https://api.github.com/users/evykassirer","html_url":"https://github.com/evykassirer","followers_url":"https://api.github.com/users/evykassirer/followers","following_url":"https://api.github.com/users/evykassirer/following{/other_user}","gists_url":"https://api.github.com/users/evykassirer/gists{/gist_id}","starred_url":"https://api.github.com/users/evykassirer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evykassirer/subscriptions","organizations_url":"https://api.github.com/users/evykassirer/orgs","repos_url":"https://api.github.com/users/evykassirer/repos","events_url":"https://api.github.com/users/evykassirer/events{/privacy}","received_events_url":"https://api.github.com/users/evykassirer/received_events","type":"User","site_admin":false},"body":"any reason why you did this instead of `return node`?","created_at":"2016-10-17T14:44:06Z","updated_at":"2016-10-17T15:01:30Z","html_url":"https://github.com/socraticorg/mathjs/pull/23#discussion_r83658818","pull_request_url":"https://api.github.com/repos/socraticorg/mathjs/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/socraticorg/mathjs/pulls/comments/83658818"},"html":{"href":"https://github.com/socraticorg/mathjs/pull/23#discussion_r83658818"},"pull_request":{"href":"https://api.github.com/repos/socraticorg/mathjs/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/socraticorg/mathjs/pulls/23","id":89118037,"html_url":"https://github.com/socraticorg/mathjs/pull/23","diff_url":"https://github.com/socraticorg/mathjs/pull/23.diff","patch_url":"https://github.com/socraticorg/mathjs/pull/23.patch","issue_url":"https://api.github.com/repos/socraticorg/mathjs/issues/23","number":23,"state":"open","locked":false,"title":"Equation support","user":{"login":"aelnaiem","id":786569,"avatar_url":"https://avatars.githubusercontent.com/u/786569?v=3","gravatar_id":"","url":"https://api.github.com/users/aelnaiem","html_url":"https://github.com/aelnaiem","followers_url":"https://api.github.com/users/aelnaiem/followers","following_url":"https://api.github.com/users/aelnaiem/following{/other_user}","gists_url":"https://api.github.com/users/aelnaiem/gists{/gist_id}","starred_url":"https://api.github.com/users/aelnaiem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aelnaiem/subscriptions","organizations_url":"https://api.github.com/users/aelnaiem/orgs","repos_url":"https://api.github.com/users/aelnaiem/repos","events_url":"https://api.github.com/users/aelnaiem/events{/privacy}","received_events_url":"https://api.github.com/users/aelnaiem/received_events","type":"User","site_admin":false},"body":"This still needs more testing and code organization.\r\n\r\nTODO:\r\n* add a lot more tests","created_at":"2016-10-13T00:26:09Z","updated_at":"2016-10-17T15:01:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b646230f6a7b546b51af1080259cbd6f1918fda3","assignee":{"login":"evykassirer","id":5634097,"avatar_url":"https://avatars.githubusercontent.com/u/5634097?v=3","gravatar_id":"","url":"https://api.github.com/users/evykassirer","html_url":"https://github.com/evykassirer","followers_url":"https://api.github.com/users/evykassirer/followers","following_url":"https://api.github.com/users/evykassirer/following{/other_user}","gists_url":"https://api.github.com/users/evykassirer/gists{/gist_id}","starred_url":"https://api.github.com/users/evykassirer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evykassirer/subscriptions","organizations_url":"https://api.github.com/users/evykassirer/orgs","repos_url":"https://api.github.com/users/evykassirer/repos","events_url":"https://api.github.com/users/evykassirer/events{/privacy}","received_events_url":"https://api.github.com/users/evykassirer/received_events","type":"User","site_admin":false},"assignees":[{"login":"evykassirer","id":5634097,"avatar_url":"https://avatars.githubusercontent.com/u/5634097?v=3","gravatar_id":"","url":"https://api.github.com/users/evykassirer","html_url":"https://github.com/evykassirer","followers_url":"https://api.github.com/users/evykassirer/followers","following_url":"https://api.github.com/users/evykassirer/following{/other_user}","gists_url":"https://api.github.com/users/evykassirer/gists{/gist_id}","starred_url":"https://api.github.com/users/evykassirer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evykassirer/subscriptions","organizations_url":"https://api.github.com/users/evykassirer/orgs","repos_url":"https://api.github.com/users/evykassirer/repos","events_url":"https://api.github.com/users/evykassirer/events{/privacy}","received_events_url":"https://api.github.com/users/evykassirer/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/socraticorg/mathjs/pulls/23/commits","review_comments_url":"https://api.github.com/repos/socraticorg/mathjs/pulls/23/comments","review_comment_url":"https://api.github.com/repos/socraticorg/mathjs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/socraticorg/mathjs/issues/23/comments","statuses_url":"https://api.github.com/repos/socraticorg/mathjs/statuses/d5756d95b060cfb5fefbe3f63d9cb5d627652e4a","head":{"label":"socraticorg:ae_equations","ref":"ae_equations","sha":"d5756d95b060cfb5fefbe3f63d9cb5d627652e4a","user":{"login":"socraticorg","id":4368132,"avatar_url":"https://avatars.githubusercontent.com/u/4368132?v=3","gravatar_id":"","url":"https://api.github.com/users/socraticorg","html_url":"https://github.com/socraticorg","followers_url":"https://api.github.com/users/socraticorg/followers","following_url":"https://api.github.com/users/socraticorg/following{/other_user}","gists_url":"https://api.github.com/users/socraticorg/gists{/gist_id}","starred_url":"https://api.github.com/users/socraticorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socraticorg/subscriptions","organizations_url":"https://api.github.com/users/socraticorg/orgs","repos_url":"https://api.github.com/users/socraticorg/repos","events_url":"https://api.github.com/users/socraticorg/events{/privacy}","received_events_url":"https://api.github.com/users/socraticorg/received_events","type":"Organization","site_admin":false},"repo":{"id":66677351,"name":"mathjs","full_name":"socraticorg/mathjs","owner":{"login":"socraticorg","id":4368132,"avatar_url":"https://avatars.githubusercontent.com/u/4368132?v=3","gravatar_id":"","url":"https://api.github.com/users/socraticorg","html_url":"https://github.com/socraticorg","followers_url":"https://api.github.com/users/socraticorg/followers","following_url":"https://api.github.com/users/socraticorg/following{/other_user}","gists_url":"https://api.github.com/users/socraticorg/gists{/gist_id}","starred_url":"https://api.github.com/users/socraticorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socraticorg/subscriptions","organizations_url":"https://api.github.com/users/socraticorg/orgs","repos_url":"https://api.github.com/users/socraticorg/repos","events_url":"https://api.github.com/users/socraticorg/events{/privacy}","received_events_url":"https://api.github.com/users/socraticorg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/socraticorg/mathjs","description":"An extensive math library for JavaScript and Node.js","fork":true,"url":"https://api.github.com/repos/socraticorg/mathjs","forks_url":"https://api.github.com/repos/socraticorg/mathjs/forks","keys_url":"https://api.github.com/repos/socraticorg/mathjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/socraticorg/mathjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/socraticorg/mathjs/teams","hooks_url":"https://api.github.com/repos/socraticorg/mathjs/hooks","issue_events_url":"https://api.github.com/repos/socraticorg/mathjs/issues/events{/number}","events_url":"https://api.github.com/repos/socraticorg/mathjs/events","assignees_url":"https://api.github.com/repos/socraticorg/mathjs/assignees{/user}","branches_url":"https://api.github.com/repos/socraticorg/mathjs/branches{/branch}","tags_url":"https://api.github.com/repos/socraticorg/mathjs/tags","blobs_url":"https://api.github.com/repos/socraticorg/mathjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/socraticorg/mathjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/socraticorg/mathjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/socraticorg/mathjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/socraticorg/mathjs/statuses/{sha}","languages_url":"https://api.github.com/repos/socraticorg/mathjs/languages","stargazers_url":"https://api.github.com/repos/socraticorg/mathjs/stargazers","contributors_url":"https://api.github.com/repos/socraticorg/mathjs/contributors","subscribers_url":"https://api.github.com/repos/socraticorg/mathjs/subscribers","subscription_url":"https://api.github.com/repos/socraticorg/mathjs/subscription","commits_url":"https://api.github.com/repos/socraticorg/mathjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/socraticorg/mathjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/socraticorg/mathjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/socraticorg/mathjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/socraticorg/mathjs/contents/{+path}","compare_url":"https://api.github.com/repos/socraticorg/mathjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/socraticorg/mathjs/merges","archive_url":"https://api.github.com/repos/socraticorg/mathjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/socraticorg/mathjs/downloads","issues_url":"https://api.github.com/repos/socraticorg/mathjs/issues{/number}","pulls_url":"https://api.github.com/repos/socraticorg/mathjs/pulls{/number}","milestones_url":"https://api.github.com/repos/socraticorg/mathjs/milestones{/number}","notifications_url":"https://api.github.com/repos/socraticorg/mathjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/socraticorg/mathjs/labels{/name}","releases_url":"https://api.github.com/repos/socraticorg/mathjs/releases{/id}","deployments_url":"https://api.github.com/repos/socraticorg/mathjs/deployments","created_at":"2016-08-26T20:28:50Z","updated_at":"2016-08-26T20:28:52Z","pushed_at":"2016-10-15T05:20:36Z","git_url":"git://github.com/socraticorg/mathjs.git","ssh_url":"git@github.com:socraticorg/mathjs.git","clone_url":"https://github.com/socraticorg/mathjs.git","svn_url":"https://github.com/socraticorg/mathjs","homepage":"mathjs.org","size":32415,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"socraticorg:ek-mathsteps","ref":"ek-mathsteps","sha":"8819454b92d821ab95e10e63fe7d5e5856ac01b4","user":{"login":"socraticorg","id":4368132,"avatar_url":"https://avatars.githubusercontent.com/u/4368132?v=3","gravatar_id":"","url":"https://api.github.com/users/socraticorg","html_url":"https://github.com/socraticorg","followers_url":"https://api.github.com/users/socraticorg/followers","following_url":"https://api.github.com/users/socraticorg/following{/other_user}","gists_url":"https://api.github.com/users/socraticorg/gists{/gist_id}","starred_url":"https://api.github.com/users/socraticorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socraticorg/subscriptions","organizations_url":"https://api.github.com/users/socraticorg/orgs","repos_url":"https://api.github.com/users/socraticorg/repos","events_url":"https://api.github.com/users/socraticorg/events{/privacy}","received_events_url":"https://api.github.com/users/socraticorg/received_events","type":"Organization","site_admin":false},"repo":{"id":66677351,"name":"mathjs","full_name":"socraticorg/mathjs","owner":{"login":"socraticorg","id":4368132,"avatar_url":"https://avatars.githubusercontent.com/u/4368132?v=3","gravatar_id":"","url":"https://api.github.com/users/socraticorg","html_url":"https://github.com/socraticorg","followers_url":"https://api.github.com/users/socraticorg/followers","following_url":"https://api.github.com/users/socraticorg/following{/other_user}","gists_url":"https://api.github.com/users/socraticorg/gists{/gist_id}","starred_url":"https://api.github.com/users/socraticorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socraticorg/subscriptions","organizations_url":"https://api.github.com/users/socraticorg/orgs","repos_url":"https://api.github.com/users/socraticorg/repos","events_url":"https://api.github.com/users/socraticorg/events{/privacy}","received_events_url":"https://api.github.com/users/socraticorg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/socraticorg/mathjs","description":"An extensive math library for JavaScript and Node.js","fork":true,"url":"https://api.github.com/repos/socraticorg/mathjs","forks_url":"https://api.github.com/repos/socraticorg/mathjs/forks","keys_url":"https://api.github.com/repos/socraticorg/mathjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/socraticorg/mathjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/socraticorg/mathjs/teams","hooks_url":"https://api.github.com/repos/socraticorg/mathjs/hooks","issue_events_url":"https://api.github.com/repos/socraticorg/mathjs/issues/events{/number}","events_url":"https://api.github.com/repos/socraticorg/mathjs/events","assignees_url":"https://api.github.com/repos/socraticorg/mathjs/assignees{/user}","branches_url":"https://api.github.com/repos/socraticorg/mathjs/branches{/branch}","tags_url":"https://api.github.com/repos/socraticorg/mathjs/tags","blobs_url":"https://api.github.com/repos/socraticorg/mathjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/socraticorg/mathjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/socraticorg/mathjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/socraticorg/mathjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/socraticorg/mathjs/statuses/{sha}","languages_url":"https://api.github.com/repos/socraticorg/mathjs/languages","stargazers_url":"https://api.github.com/repos/socraticorg/mathjs/stargazers","contributors_url":"https://api.github.com/repos/socraticorg/mathjs/contributors","subscribers_url":"https://api.github.com/repos/socraticorg/mathjs/subscribers","subscription_url":"https://api.github.com/repos/socraticorg/mathjs/subscription","commits_url":"https://api.github.com/repos/socraticorg/mathjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/socraticorg/mathjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/socraticorg/mathjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/socraticorg/mathjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/socraticorg/mathjs/contents/{+path}","compare_url":"https://api.github.com/repos/socraticorg/mathjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/socraticorg/mathjs/merges","archive_url":"https://api.github.com/repos/socraticorg/mathjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/socraticorg/mathjs/downloads","issues_url":"https://api.github.com/repos/socraticorg/mathjs/issues{/number}","pulls_url":"https://api.github.com/repos/socraticorg/mathjs/pulls{/number}","milestones_url":"https://api.github.com/repos/socraticorg/mathjs/milestones{/number}","notifications_url":"https://api.github.com/repos/socraticorg/mathjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/socraticorg/mathjs/labels{/name}","releases_url":"https://api.github.com/repos/socraticorg/mathjs/releases{/id}","deployments_url":"https://api.github.com/repos/socraticorg/mathjs/deployments","created_at":"2016-08-26T20:28:50Z","updated_at":"2016-08-26T20:28:52Z","pushed_at":"2016-10-15T05:20:36Z","git_url":"git://github.com/socraticorg/mathjs.git","ssh_url":"git@github.com:socraticorg/mathjs.git","clone_url":"https://github.com/socraticorg/mathjs.git","svn_url":"https://github.com/socraticorg/mathjs","homepage":"mathjs.org","size":32415,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/socraticorg/mathjs/pulls/23"},"html":{"href":"https://github.com/socraticorg/mathjs/pull/23"},"issue":{"href":"https://api.github.com/repos/socraticorg/mathjs/issues/23"},"comments":{"href":"https://api.github.com/repos/socraticorg/mathjs/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/socraticorg/mathjs/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/socraticorg/mathjs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/socraticorg/mathjs/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/socraticorg/mathjs/statuses/d5756d95b060cfb5fefbe3f63d9cb5d627652e4a"}}}}
{"actor":{"display_login":"evykassirer"}}