use Proc::ZMQed::Mathematica; my Proc::ZMQed::Mathematica $wlProc .= new(url => 'tcp://127.0.0.1', port => '5550'); $wlProc.start-proc():!proclaim; my $cmd = 'Expand[(x+y)^4]'; my $wlRes = $wlProc.evaluate($cmd); say "Sent : $cmd"; say "Got :\n $wlRes"; $cmd = 'FortranForm[Expand[($x+$y)^4]]'; $wlRes = $wlProc.evaluate($cmd); say "Sent : $cmd"; say "Got : $wlRes"; my $x = 5; my $y = 3; use MONKEY-SEE-NO-EVAL; say "Using : {{:$x, :$y}.raku}"; say 'EVAL($wlRes) : ', EVAL($wlRes); $cmd = 'D[(x+y)^3, x]'; $wlRes = $wlProc.evaluate($cmd); say "Sent : $cmd"; say "Got :\n $wlRes"; $cmd = 'sol = DSolve[{y\'[x] == -3 y[x]^2, y[1] == 2}, y[x], x]'; $wlRes = $wlProc.evaluate($cmd); say "Sent : $cmd"; say "Got :\n {$wlRes}"; $cmd='p=Plot[y[x] /. sol, {x, 1, 4}]; ps=ExportString[p,{"Base64","PNG"}]; Export["/tmp/wlimg.txt",ps]'; $wlRes = $wlProc.evaluate($cmd); use Text::Plot; my $timg=slurp('/tmp/wlimg.txt'); from-base64($timg) my $dt = now.DateTime.Str.substr(0,19); say $dt; $cmd = ' p=ClockGauge["' ~ $dt ~ '"]; ps=ExportString[p,{"Base64","PNG"}]; Export["/tmp/wlimg.txt",ps]'; $wlRes = $wlProc.evaluate($cmd); my $timg=slurp('/tmp/wlimg.txt'); from-base64($timg) $cmd = 'GeoNearest["Ocean", Here]'; $wlRes = $wlProc.evaluate($cmd); say "Sent : $cmd"; say "Got :\n {$wlRes.raku}"; $cmd = 'loc = FindGeoLocation["Miami, FL"]'; $wlRes = $wlProc.evaluate($cmd); say "Sent : $cmd"; say "Got :\n {$wlRes.raku}"; $cmd = 'res = GeoNearest["City", loc, {7, Quantity[30, "Miles"]}]; res2 = Map[{#["Name"], QuantityMagnitude@UnitConvert[GeoDistance[loc, #],"Kilometers"]}&, res]'; $wlRes = $wlProc.evaluate($cmd); say "Sent : $cmd"; say "Got :\n {$wlRes.raku}"; $cmd = 'p=GeoGraphics[GeoMarker/@GeoNearest["City", loc, {7, Quantity[30, "Miles"]}]];ps=ExportString[p,{"Base64","PNG"}]; Export["/tmp/wlimg.txt",ps]'; $wlRes = $wlProc.evaluate($cmd); my $timg=slurp('/tmp/wlimg.txt'); from-base64($timg) $cmd = 'WolframAlpha["Earth distance from Sun", "Result"]'; $wlRes = $wlProc.evaluate($cmd); say "Sent : $cmd"; say "Got :\n {$wlRes.raku}"; $cmd = 'WolframAlpha["calories in 20 servings of ice cream", "Result"]'; $wlRes = $wlProc.evaluate($cmd); say "Sent : $cmd"; say "Got :\n {$wlRes.raku}"; $cmd = 'p=WolframAlpha["calories in 20 servings of potato salad", {{"NutritionLabelSingle:ExpandedFoodData", 1}, "Image"}]; ps=ExportString[p,{"Base64","PNG"}]; Export["/tmp/wlimg.txt",ps]'; $wlRes = $wlProc.evaluate($cmd); $timg=slurp('/tmp/wlimg.txt'); from-base64($timg) $cmd = ' p=ResourceFunction["RandomMondrian"][]; ps=ExportString[p,{"Base64","PNG"}]; Export["/tmp/wlimg.txt",ps]'; $wlRes = $wlProc.evaluate($cmd); my $timg=slurp('/tmp/wlimg.txt'); from-base64($timg) $cmd = ' p=ResourceFunction["RandomMandala"]["Radius"->{10,8,4},"ConnectingFunction"->FilledCurve@*BezierCurve,ColorFunction -> "Rainbow",Background->Automatic]; ps=ExportString[p,{"Base64","PNG"}]; Export["/tmp/wlimg.txt",ps]'; $wlRes = $wlProc.evaluate($cmd); my $timg=slurp('/tmp/wlimg.txt'); from-base64($timg) #$wlProc.terminate