This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'open-uri' | |
require 'json' | |
def get_page(url) | |
uri = URI(url) | |
search = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| | |
request = Net::HTTP::Get.new uri | |
response = http.request request | |
response.body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Lisp do | |
@doc "Removes the wrapping parenthesis and breaks the expression up into individual arguments and sub-expressions, then parses each of those" | |
def parse("(" <> lisp) do | |
remove_parens = String.slice(lisp, 0..-2) | |
Regex.scan(~r/(?:\(.*\)|[^\s]+)/, remove_parens) | |
|> List.flatten | |
|> Enum.map(&parse/1) | |
end | |
@doc "parses individual operators and arguments. Currently all it does is convert numbers" |