mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-11 04:27:55 +03:00
Renamed initialize. Cons also works for array
This commit is contained in:
parent
8d49d76279
commit
0d3c5cc6ab
@ -117,7 +117,7 @@ arrayModule = Env { envBindings = bindings, envParent = Nothing, envModuleName =
|
||||
where bindings = Map.fromList [ templateNth
|
||||
, templateReplicate
|
||||
, templateRepeat
|
||||
, templateInitialize
|
||||
, templateRepeatIndexed
|
||||
, templateCopyingMap
|
||||
, templateEMap
|
||||
, templateFilter
|
||||
|
@ -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 ->
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user