How to send Map[Plus[1, #] &, {1, 2, 3}] to Mathematica from C# via IKernelLink?

Here is a piece of my code

using System;

namespace ns_01_Wolfram
{
public class Test
{

public Test()
{

// Map[Plus[1, #] &, {1, 2, 3}]
byte[] array = { 1, 2, 3 };
Expr exprMap = new Expr(ExpressionType.Symbol, "Map");        // Map
Expr exprPlus = new Expr(ExpressionType.Symbol, "Plus");      // Plus
Expr exprSharp = new Expr(ExpressionType.Symbol, "#");        // #
Expr exprAnd = new Expr(ExpressionType.Symbol, "&");          // &
Expr exprPlusParam = new Expr(exprPlus, 5, exprSharp);        // Plus[5,#]
Expr exprPlusParamAnd = new Expr(exprPlusParam, exprAnd);     // !!! HERE I NEED => Plus[5,#] & <= INSTEAD OF => Plus[5,#] [&]
Expr exprFinal = new Expr(exprMap, exprPlusParamAnd, array);  // Map[Plus[5,#] &, {1,2,3}]}
String result = ml.EvaluateToOutputForm(exprFinal, 0);        // Result = {2, 3, 4}


On 3rd line from bottom I NEED TO GET {Plus[5,#] &} INSTEAD OF Plus[5,#] [&].

Any idea ?

• I don't have experience with this but it seems you are building the pure function incorrectly. See FullForm@{Plus[5, #] &} – Kuba Oct 11 '17 at 17:14
• I don't have experience with NET/Link, but when using MathLink from C, you can send an expression as a string. If the expression is constant, this is much easier than building it programmatically. – Szabolcs Oct 11 '17 at 17:50
• Finally solved using Table[] instead of pure function. – Emilio Oct 13 '17 at 20:45