Commits

Anonymous committed a2a40b5

[svn r528] __make_function is working, see if we can plug it instead on let

  • Participants
  • Parent commits 688cd92

Comments (0)

Files changed (1)

 function __make_function {
 	local __func="$@"
 
-	local __function_pattern='^\w\+[[:space:]]*=[[:space:]]*'
-	if echo "$__func" | grep -q "$__function_pattern" ; then
+	local __lambda_pattern='^\w\+[[:space:]]*=[[:space:]]*'
+	local __function_pattern='^\w\+\([[:space:]]\+\w\+\)\+[[:space:]]*=[[:space:]]*'
+	local __ok=
+	if echo "$__func" | grep -q "$__lambda_pattern" ; then
 		local __name=${__func%%=*}
 		local __body=${__func#*=}
 		__body=$(__make_lambda 0 "$__body")
-		
-		local __code="\
+	elif echo "$__func" | grep -q "$__function_pattern" ; then
+		local __name=
+		local __args=
+		read -r __name __args <<<${__func%%=*}
+		local __body=${__func#*=}
+		__body=$(__make_lambda 0 "\\$__args -> $__body")
+	else
+		__die "function syntax error near '$__func'"
+	fi
+	
+	local __code="\
 function $__name { \
 	local __i=1 ;\
 	local __a= ;\
 	done ;\
 	$__body ;\
 }"
-		eval "$__code"
-	else
-		__die "function syntax error near '$__func'"
-	fi
+	eval "$__code"
 }