I am making a program in C# (using Visual Studio) which uses IronScheme, and this is a snippet of code I have.
exp = "(car '('(1 2 3) 4 5 6))";
System.Console.WriteLine(exp.Eval());
Basically, I want to get the first element of that list, which is another list (1 2 3)
. My problem is I don't know how to obtain the actual list of number. In this example, I'm printing the result of the Eval()
, which prints:
IronScheme.Runtime.Cons
If I convert it to string, I get the same result. And any other type cast/conversion prints the same thing
System.Console.WriteLine(exp.Eval().ToString());
// Also prints "IronScheme.Runtime.Cons"
How do I get the values of that list, as C# list List<>
?
Cons
implementsIEnumerable
.One problem you have is the quoted list inside an already quoted list. I am not sure if this what you want, but I am removing it for the example:
Protip: You can use
Cons.PrettyPrint
to see the content expanded in a more readable format.