File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ module Foreign.Matlab.Array (
31
31
-- | array list access
32
32
mxArrayGetList , mxArraySetList ,
33
33
mxArrayGetAll , mxArraySetAll ,
34
+ fromListIO ,
34
35
35
36
-- * Struct access
36
37
-- | Structs in Matlab are always arrays, and so can be accessed using most array accessors.
@@ -126,6 +127,13 @@ foreign import ccall unsafe mxDestroyArray :: MXArrayPtr -> IO ()
126
127
freeMXArray :: MXArray a -> MIO ()
127
128
freeMXArray a = withMXArray a mxDestroyArray
128
129
130
+ -- | Create and populate an MXArray in one go.
131
+ fromListIO :: MXArrayComponent a => [a ] -> MIO (MXArray a )
132
+ fromListIO xs = do
133
+ arr <- createMXArray [length xs]
134
+ mxArraySetAll arr xs
135
+ pure arr
136
+
129
137
-- | The class of standardly typeable array elements
130
138
class MXArrayComponent a where
131
139
-- | Determine whether the given array is of the correct type
You can’t perform that action at this time.
0 commit comments