From cbee5f87054a68eb005fe7f50bb375dcd2a6b37f Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Wed, 1 Mar 2023 00:41:34 +0800 Subject: [PATCH] :sparkles: add std lib mat.nas --- stl/mat.nas | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 stl/mat.nas diff --git a/stl/mat.nas b/stl/mat.nas new file mode 100644 index 0000000..600fcf9 --- /dev/null +++ b/stl/mat.nas @@ -0,0 +1,148 @@ + +var mat=func(width,height) { + var res=[]; + setsize(res,width*height); + forindex(var i;res) { + res[i]=0; + } + return { + width:width, + height:height, + mat:res + }; +} + +var rand_init=func(a) { + srand(); + var ref=a.mat; + forindex(var i;ref) { + ref[i]=rand(); + } +} + +var mat_print=func(a) { + var (width,height,ref)=(a.width,a.height,a.mat); + for(var i=0;i