But I like to know if there is there a builtin function to find out the type of a symbol/variable/defn which I can use such as

eg:

Code: Select all

```
(type x) => "list"
(type n) => "integer"
etc...
```

The newlisp manual has predicates.

But I like to know if there is there a builtin function to find out the type of a symbol/variable/defn which I can use such as

eg:

But I like to know if there is there a builtin function to find out the type of a symbol/variable/defn which I can use such as

eg:

Code: Select all

```
(type x) => "list"
(type n) => "integer"
etc...
```

There is no built-in function that I know of that can return the type of any newLISP expression. At best, you may be able to construct your own function that uses the existing predicate functions to return a string that is unique for each cell type.

Code: Select all

```
(define types '("nil" "true" "int" "float" "string" "symbol" "context"
"primitive" "import" "ffi" "quote" "expression" "lambda" "fexpr" "array"
"dyn_symbol"))
(define (typeof v)
(types (& 0xf ((dump v) 1))))
```

Thanks everyone.

Despite ofryuo wrote:There is no built-in function that I know of that can return the type of any newLISP expression. At best, you may be able to construct your own function that uses the existing predicate functions to return a string that is unique for each cell type.

Code: Select all

```
(define (type x)
(let (types
'("bool" "bool" "integer" "float"
"string" "symbol" "context" "primitive"
"import-simple" "import-libffi" "quote" "list" "lambda"
"fexpr" "array"))
(types (& 0xf ((dump x) 1)))))
```

Code: Select all

`(lambda? lambda?) -> nil`