Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/._?NumberQ->0/.x_String:>StringReplace[x,_->" "]&
- StringReplace[#,_->" "]~Check~#&//@#/._?NumberQ->0&
- #/._?NumberQ->0
- .../.x_String:>StringReplace[x,_->" "]
- StringReplace[#,_->" "]~Check~#&//@...
- InstallOtherMethod(Zero,[IsChar],c->' ');
- InstallOtherMethod(Zero,[IsList],l->List(l,Zero));
- gap> Zero([[["H"],"e",1,1,0],[[-3],"arth"]]);
- [ [ [ " " ], " ", 0, 0, 0 ], [ [ 0 ], " " ] ]
- f:=function(x)if IsInt(x)then return 0;elif IsList(x)then return List(x,f);fi;return' ';end;
- f=->a{a.map{|x|x*0==0?0:x*0==""?x.gsub(/./," "):f[x]}}
- class N a where n::a->a
- instance N Int where n _=0
- instance N Char where n _=' '
- instance N a=>N[a]where n=map n
- *Main> n (42::Int)
- 0
- *Main> n "hi"
- " "
- *Main> n ([[1,2],[3,4,5]]::[[Int]])
- [[0,0],[0,0,0]]
- *Main> n ["hello","world!"]
- [" "," "]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement