43 lines
1.0 KiB
Plaintext
43 lines
1.0 KiB
Plaintext
DECLARE (*ambassert)() TYPE NUMBER
|
|
|
|
FUNCTION amb_recurse$(text$[], nr, total, result$)
|
|
|
|
LOCAL ctr
|
|
LOCAL str$, test$
|
|
|
|
FOR ctr = 1 TO AMOUNT(text$[nr])
|
|
str$ = APPEND$(result$, 0, TOKEN$(text$[nr], ctr))
|
|
IF nr = total-1 THEN
|
|
IF ambassert(str$) THEN RETURN str$
|
|
ELSE
|
|
test$ = amb_recurse$(text$, nr+1, total, str$)
|
|
IF AMOUNT(test$) = total THEN RETURN test$
|
|
ENDIF
|
|
NEXT
|
|
|
|
RETURN ""
|
|
|
|
ENDFUNC
|
|
|
|
FUNCTION ambsel$(VAR data$ SIZE dim)
|
|
|
|
RETURN IIF$(dim < 2, "ambsel$ needs more than 1 argument", amb_recurse$(data$, 0, dim, ""))
|
|
|
|
ENDFUNC
|
|
|
|
FUNCTION this_is_some_constraint(var$)
|
|
|
|
DOTIMES AMOUNT(var$)-1
|
|
IF RIGHT$(TOKEN$(var$, _), 1) != LEFT$(TOKEN$(var$, _+1), 1) THEN RETURN FALSE
|
|
DONE
|
|
|
|
RETURN TRUE
|
|
|
|
ENDFUNC
|
|
|
|
' AMBASSERT: pointing to a constraint function
|
|
ambassert = this_is_some_constraint
|
|
|
|
' AMBSEL$: generate result from arguments in delimited string format
|
|
PRINT ambsel$("the that a", "frog elephant thing", "walked treaded grows", "slowly quickly")
|