# Dynamically apply a function fed by Input[]

Here is a bit of code:

funlist = {Plot,ListPlot};


The idea here is to select what function you want to use (Plot or ListPlot in that case) and to give the expression you want to be evaluated by this function (for example x,{x,0,1} for Plot).

I have been struggling with this code for a few hours so if anyone has an idea.

I am aware that something like:

PopupMenu[Dynamic@whichfun, funlist]
InputField[Dynamic[expr], String, ContinuousAction -> True]
Dynamic@(whichfun @@ (ToExpression@expr))


with InputField fed by {x, {x, 0, 1}} would work.

-
Input is a must? –  Kuba Oct 1 '13 at 15:58
Input is a wish*. If it's not possible then I'll give up. –  Öskå Oct 1 '13 at 16:00
You could strip away the Dynamic stuff that gets in the way: Input[....]/. Dynamic[f_, ___] :> f –  ssch Oct 1 '13 at 16:05
@ssch, it indeed works! Answer it? –  Öskå Oct 1 '13 at 16:13

This feels like a bit of a hack but at least works. The output looks something like:

(Plot)[x,{x,0,1}]//InputForm
(* Dynamic[whichfun, ImageSizeCache -> {33., {0., 8.}}][x, {x, 0, 1}] *)


After stripping away that Dynamic it works as expected:

funlist = {Plot, ListPlot};
Input[