Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Trailing comment identifier drill (this is not a script that adds any real value, IMO, but an interesting challenge nevertheless)
- function IsWithinQuotes(x::String, ind::Int64, n::Int64 = length(x))
- OpenQuotes = false
- for i = 1:ind
- if x[i] == '"'; OpenQuotes = !OpenQuotes; end
- end
- if OpenQuotes
- for i = (ind+1):n
- if x[i] == '"'; return true; end
- end
- end
- return false
- end
- function main(x::String) # x is a line of code
- n = length(x)
- for i = 1:n
- if x[i] == '#'
- if !IsWithinQuotes(x, i, n); return true; end
- end
- end
- return false
- end
Add Comment
Please, Sign In to add comment