Renamed initialize. Cons also works for array

This commit is contained in:
Thomas Dendale 2018-01-24 16:30:59 +01:00
parent 8d49d76279
commit 0d3c5cc6ab
3 changed files with 5 additions and 4 deletions

View File

@ -117,7 +117,7 @@ arrayModule = Env { envBindings = bindings, envParent = Nothing, envModuleName =
where bindings = Map.fromList [ templateNth
, templateReplicate
, templateRepeat
, templateInitialize
, templateRepeatIndexed
, templateCopyingMap
, templateEMap
, templateFilter

View File

@ -243,9 +243,9 @@ templateRepeat = defineTypeParameterizedTemplate templateCreator path t
depsForDeleteFunc typeEnv env arrayType)
templateInitialize :: (String, Binder)
templateInitialize = defineTypeParameterizedTemplate templateCreator path t
where path = SymPath ["Array"] "initialize"
templateRepeatIndexed :: (String, Binder)
templateRepeatIndexed = defineTypeParameterizedTemplate templateCreator path t
where path = SymPath ["Array"] "repeat-indexed"
t = FuncTy [IntTy, FuncTy [IntTy] (VarTy "t")] (StructTy "Array" [VarTy "t"])
templateCreator = TemplateCreator $
\typeEnv env ->

View File

@ -394,6 +394,7 @@ commandCons :: CommandCallback
commandCons [x, xs] =
case xs of
XObj (Lst lst) _ _ -> return (Right (XObj (Lst (x : lst)) (info x) (ty x))) -- TODO: probably not correct to just copy 'i' and 't'?
XObj (Arr arr) _ _ -> return (Right (XObj (Arr (x : arr)) (info x) (ty x)))
_ -> return (Left (EvalError "Applying 'cons' to non-list or empty list."))
commandConsLast :: CommandCallback