Has
Has[symbol]
Has[object, key]
A polymorphic function that checks for existence in the current environment or within an object.
- Single argument: Returns
#tifsymbolis defined in the current scope, otherwise#f. - Two arguments: Returns
#tifkeyexists inobject, otherwise#f.
(* Symbol existence *)
Has[Has]; (* => #t *)
Has[a]; (* => #f *)
Let[a, 0];
Has[a]; (* => #t *)
(* Object key existence *)
Let[obj, Object[A, { { #a, 1 } }]];
Has[obj, #a]; (* => #t *)
Has[obj, #b]; (* => #f *)
Head
Head[list]
Retrieves the first element of list.
- Returns the first element of the list.
- An error is raised if
listis empty.
Head[{ 1, 2, 3 }]; (* => 1 *)
Head[{ { #a, #b }, #c }]; (* => {#a, #b} *)
Head[{ }];
(*? Error[ksl::builtin::Head]: Empty list. *)