首页 > 解决方案 > str-split 函数有什么作用?

问题描述

(str-split) 函数在此构建中做了 什么https://sourceforge.net/p/clipsrules/code/HEAD/tree/branches/63x/core/ PS 我知道 (string-split) 函数在其他语言中的作用,如 C++、C#、Java、Python。但在这里,我无法理解。赖利先生,一切都希望你)))

标签: splitclips

解决方案


(deffunction MAIN::str-split (?separator ?str)
    (bind $?result (create$))
    (bind ?index 1)
    (while (> (str-length ?str) 0)
        (bind ?index (str-index ?separator ?str))
        (if (neq ?index FALSE) 
            then
                (bind ?temp_string (sub-string 1 (- ?index 1) ?str))
                (if (neq ?temp_string "") 
                    then
                        (bind $?result (insert$ $?result (+ (length$ $?result) 1)
                            (create$ ?temp_string)))
                )
                (bind ?str (sub-string (+ ?index 1) (str-length ?str) ?str))
            else
                (bind $?result (insert$ $?result (+ (length$ $?result) 1) (create$ ?str)))
                (return $?result)
        )
    )
    (return $?result)
)

推荐阅读