9 lines
232 B
CoffeeScript
9 lines
232 B
CoffeeScript
|
{nilp, car, cdr} = require './lists'
|
||
|
|
||
|
module.exports = lookup = (scopes, name) ->
|
||
|
throw new Error "Unknown variable '#{name}'" if nilp scopes
|
||
|
scope = car scopes
|
||
|
return scope[name] if scope[name]?
|
||
|
lookup((cdr scopes), name)
|
||
|
|