#!/usr/bin/env python

from nodes import Node
from node.string_literal import StringLiteral 

class Split(Node):
    char = "c"
    args = 2
    results = 1
    
    @Node.test_func(["1 2 1", " "], [["1", "2", "1"]])
    @Node.test_func(["1,3,4", ","], [["1", "3", "4"]])
    def split(self, inp:str, split:str):
        """inp.split(`arg`)"""
        return [inp.split(split)]
    
    def chunk(self, inp:Node.indexable, size:Node.number):
        """Return inp seperated into groups sized size"""
        size = float(size)
        rtn = []
        last = 0
        for i, val in enumerate(inp):
            cur = i%size
            if cur <= last: rtn.append([])
            rtn[-1].append(val)
            last = cur
        return [rtn]
    
    def floor_remainder(self, a:Node.number, multiple:Node.number):
        """a-(a%multiple)"""
        return a-(a%multiple)
    
@@ -151,24 +151,112 @@
 ts = 1%0A    %0A
+    def prepare(self, stack):%0A        if len(stack) %3C 2:%0A            self.args = 1%0A    %0A
     @Node.te
@@ -460,24 +460,124 @@
 plit)%5D%0A    %0A
+    @Node.test_func(%5B%22134%22, 1%5D, %5B%5B%221%22, %223%22, %224%22%5D%5D)%0A    @Node.test_func(%5B%221234%22, 2%5D, %5B%5B%2212%22, %2234%22%5D%5D)%0A
     def chun
@@ -836,99 +836,596 @@
 ast:
- rtn.append(%5B%5D)%0A            rtn%5B-1%5D.append(val)%0A            last = cur%0A        return %5Brtn%5D
+%0A                if len(rtn):%0A                    if isinstance(inp, str):%0A                        rtn%5B-1%5D = %22%22.join(rtn%5B-1%5D)%0A                    else:%0A                        rtn%5B-1%5D = type(inp)(rtn%5B-1%5D)%0A                rtn.append(%5B%5D)%0A            rtn%5B-1%5D.append(val)%0A            last = cur%0A        if len(rtn):%0A            if isinstance(inp, str):%0A                rtn%5B-1%5D = %22%22.join(rtn%5B-1%5D)%0A            else:%0A                rtn%5B-1%5D = type(inp)(rtn%5B-1%5D)%0A        return %5Brtn%5D%0A    %0A    def split_space(self, inp:str):%0A        %22%22%22return inp.split(%22 %22)%22%22%22%0A        return self.split(inp, %22 %22)
 %0A   

Add split on space if stack is 1 Add tests for chunk