Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit class DataTable:ver<0.0.1>:auth<github:tushardave26>;
- #custom types
- subset Int-or-Str where Int|Str;
- #attributes
- has Array @.data is rw = [];
- has Int-or-Str @.header is rw = [];
- has Int $.type is readonly = 0;
- #methods
- # This method performs several sanity checks.
- method !sanity-check {
- # 1. check whether all elements of all arrays of array of arrays (i.e. data) is equal or not
- unless [==] self@!data {
- fail "The number of observations in each rows are not equal.!!";
- }
- # 2. check whether the number of observation meaning number elements in a row is equal to
- # number of columns or not
- unless @!data.[0].elems == @!header.elems {
- fail "The number of observations and number of columns are not equal.!!";
- }
- # call sanity-check method within it definition
- #self!sanity-check();
- }
- #my @a = [1,2,3], [4,5,6]; say [==] @a
- method dim {
- # check the provided data consistency and other possible issues
- self!sanity-check;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement