- Else
- Dim a0 As MalVal = DirectCast(ast,MalList)(0)
- If TypeOf a0 Is MalSymbol AndAlso _
- DirectCast(a0,MalSymbol).getName() = "unquote" Then
- return DirectCast(ast,MalList)(1)
- Else If is_pair(a0) Then
- Dim a00 As MalVal = DirectCast(a0,MalList)(0)
- If TypeOf a00 is MalSymbol AndAlso _
- DirectCast(a00,MalSymbol).getName() = "splice-unquote" Then
- return New MalList(New MalSymbol("concat"),
- DirectCast(a0,MalList)(1),
- quasiquote(DirectCast(ast,MalList).rest()))
- End If
+ End If
+ Const source As MalList = TryCast(ast, MalList)
+ If source Is Nothing Then
+ return ast
+ End If
+ Const unquoted As MalVal = starts_with(ast, "unquote")
+ If unquoted IsNot Nothing Then
+ return unquoted
+ End If
+ Dim result As MalList = New MalList()
+ For i As Integer = source.size()-1 To 0 Step -1
+ Const elt As MalVal = source(i)
+ Const splice_unquoted As MalVal = starts_with(elt, "splice-unquote")
+ If splice_unquoted IsNot Nothing Then
+ result = New MalList(New MalSymbol("concat"), splice_unquoted, result)
+ Else
+ result = New MalList(New MalSymbol("cons"), quasiquote(elt), result)