1
1
package ari
2
2
3
3
import (
4
- "bufio"
5
4
_ "embed"
6
5
"fmt"
7
6
"os"
@@ -70,34 +69,6 @@ var goalSourceAri string
70
69
71
70
// Goal functions implemented in Go
72
71
73
- // printV adapted from Goal's implementation found in the os.go file.
74
- func printV (ctx * goal.Context , x goal.V ) error {
75
- switch xv := x .BV ().(type ) {
76
- case goal.S :
77
- _ , err := fmt .Fprint (os .Stdout , string (xv ))
78
- return err
79
- case * goal.AS :
80
- buf := bufio .NewWriter (os .Stdout )
81
- imax := xv .Len () - 1
82
- for i , s := range xv .Slice {
83
- _ , err := buf .WriteString (s )
84
- if err != nil {
85
- return err
86
- }
87
- if i < imax {
88
- err := buf .WriteByte (' ' )
89
- if err != nil {
90
- return err
91
- }
92
- }
93
- }
94
- return buf .Flush ()
95
- default :
96
- _ , err := fmt .Fprintf (os .Stdout , "%s" , x .Append (ctx , nil , false ))
97
- return err
98
- }
99
- }
100
-
101
72
// Implements Goal's help monad + Ari's help dyad.
102
73
func VFGoalHelp (help Help ) func (_ * goal.Context , args []goal.V ) goal.V {
103
74
return func (_ * goal.Context , args []goal.V ) goal.V {
@@ -138,7 +109,7 @@ func helpDyadic(help Help, x goal.V, args []goal.V) goal.V {
138
109
}
139
110
140
111
// Implements rtnames monad.
141
- func VFRTNames (goalContext * goal.Context , args []goal.V ) goal.V {
112
+ func VFRTNames (goalContext * goal.Context , _ []goal.V ) goal.V {
142
113
names := goalContext .GlobalNames (nil )
143
114
goalContext .Keywords (names )
144
115
prims := make ([]string , 0 )
@@ -149,12 +120,16 @@ func VFRTNames(goalContext *goal.Context, args []goal.V) goal.V {
149
120
}
150
121
primsSeen [prim ] = true
151
122
}
152
- keys := make ([]string , 0 , len (GoalSyntax ()))
153
- for k := range GoalSyntax () {
154
- keys = append (keys , k )
155
- }
156
- ks := goal .NewArray ([]goal.V {goal .NewS ("globals" ), goal .NewS ("keywords" ), goal .NewS ("verbs" )})
157
- vs := goal .NewArray ([]goal.V {goal .NewAS (goalContext .GlobalNames (nil )), goal .NewAS (goalContext .Keywords (nil )), goal .NewAS (prims )})
123
+ ks := goal .NewArray ([]goal.V {
124
+ goal .NewS ("globals" ),
125
+ goal .NewS ("keywords" ),
126
+ goal .NewS ("verbs" ),
127
+ })
128
+ vs := goal .NewArray ([]goal.V {
129
+ goal .NewAS (goalContext .GlobalNames (nil )),
130
+ goal .NewAS (goalContext .Keywords (nil )),
131
+ goal .NewAS (prims ),
132
+ })
158
133
return goal .NewDict (ks , vs )
159
134
}
160
135
@@ -183,18 +158,6 @@ func stringMapFromGoalDict(d *goal.D) (map[string]string, error) {
183
158
return m , nil
184
159
}
185
160
186
- func stringMapToGoalDict (m map [string ]string ) goal.V {
187
- keys := make ([]string , 0 , len (m ))
188
- values := make ([]string , 0 , len (m ))
189
- for k , v := range m {
190
- keys = append (keys , k )
191
- values = append (values , v )
192
- }
193
- ks := goal .NewAS (keys )
194
- vs := goal .NewAS (values )
195
- return goal .NewD (ks , vs )
196
- }
197
-
198
161
func goalNewDictEmpty () * goal.D {
199
162
dv := goal .NewD (goal .NewAV (nil ), goal .NewAV (nil ))
200
163
d , ok := dv .BV ().(* goal.D )
0 commit comments