public ChunkedSeq(PersistentVector vec, int i, int offset) { _vec = vec; _i = i; _offset = offset; _node = vec.ArrayFor(i); }
static public PersistentVector create(ISeq items) { Object[] arr = new Object[32]; int i = 0; for (; items != null && i < 32; items = items.next()) { arr[i++] = items.first(); } if (items != null) { // >32, construct with array directly PersistentVector start = new PersistentVector(32, 5, EmptyNode, arr); TransientVector ret = (TransientVector)start.asTransient(); for (; items != null; items = items.next()) { ret = (TransientVector)ret.conj(items.first()); } return((PersistentVector)ret.persistent()); } else if (i == 32) { // exactly 32, skip copy return(new PersistentVector(32, 5, EmptyNode, arr)); } else { // <32, copy to minimum array and construct Object[] arr2 = new Object[i]; Array.Copy(arr, 0, arr2, 0, i); return(new PersistentVector(i, 5, EmptyNode, arr2)); } }
public ChunkedSeq(PersistentVector vec, object[] node, int i, int offset) { _vec = vec; _node = node; _i = i; _offset = offset; }
public static DataSeries AddNewCurrentDataSeries(PersistentVector initialPoints, string name, Color? color) { DataSeries ds = new DataSeries(Utility.PVtoGPList(initialPoints), name, color); CurrentDataSeries = AllDataSeries.Count - 1; UpdateSeriesInfoInUI(); return ds; }
ChunkedSeq(IPersistentMap meta, PersistentVector vec, object[] node, int i, int offset) : base(meta) { _vec = vec; _node = node; _i = i; _offset = offset; }
static public IPersistentVector create(System.Collections.ICollection coll) { if (!(coll is ISeq) && coll.Count <= 32) { object[] array = new object[coll.Count]; coll.CopyTo(array, 0); return(createOwning(array)); } return(PersistentVector.create(RT.seq(coll))); }
static public IPersistentVector createOwning(params object[] items) { //if (items.Length <= Tuple.MAX_SIZE) // return Tuple.createFromArray(items); //else if (items.Length <= 32) { return(new PersistentVector(items.Length, 5, PersistentVector.EmptyNode, items)); } return(PersistentVector.create(items)); //: new LazilyPersistentVector(null, items, null); }
public static void AddClojureButtons(PersistentVector vec) { List<Button> buttons = new List<Button>(); for (int i = 0; i < vec.Count; i += 2) { if (!(vec[i + 1] is IFn)) continue; buttons.Add(CreateClojureButton(vec[i].ToString(), (IFn)vec[i + 1])); } ClojureDefinedUI.self.AddNewClojureControls(buttons.ToArray()); }
static public IPersistentVector createOwning(params object[] items) { if (items.Length == 0) { return((IPersistentVector)PersistentVector.EMPTY); } else if (items.Length <= 32) { return(new PersistentVector(items.Length, 5, PersistentVector.EmptyNode, items)); } return(PersistentVector.create(items)); //: new LazilyPersistentVector(null, items, null); }
public static List<GraphPoint> PVtoGPList(PersistentVector pv) { List<GraphPoint> points = new List<GraphPoint>(); int count = 0; foreach (object obj in pv) { if (count > ClojureEngine.ClojureMaxIterations) break; try { points.Add((GraphPoint)obj); ++count; } catch { } } return points; }
public static void AddClojureDropDownBox(string labelText, Var variable, PersistentVector vals, IFn func) { string variableSymbolName = null; if(variable != null) variableSymbolName = variable.sym.Name; Label label = new Label(); label.AutoSize = true; label.Text = labelText; Dictionary<string, object> labelCodeAssoc = new Dictionary<string, object>(); ComboBox comboBox = new ComboBox(); for (int i = 0; i < vals.Count; i += 2) { labelCodeAssoc.Add(vals[i].ToString(), vals[i + 1]); comboBox.Items.Add(vals[i]); } comboBox.SelectedIndex = 0; comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.SelectedIndexChanged += (s, e) => { if (comboBox.SelectedItem == null) return; object code = labelCodeAssoc[comboBox.SelectedItem.ToString()]; if(variableSymbolName != null) { string newVal = code.ToString(); ClojureEngine.Eval("(def " + variableSymbolName + " " + newVal + ")"); } if (func != null) ClojureEngine.Log(func.invoke()); }; self.AddNewClojureControls(new Control[] { label, comboBox }); }
static public IPersistentVector create(object obj) { //if ((obj is Counted || RT.SupportsRandomAccess(obj)) // && fcount(obj) <= Tuple.MAX_SIZE) // return Tuple.createFromColl(obj); if (obj is IReduceInit ri) { return(PersistentVector.create(ri)); } if (obj is ISeq) { return(PersistentVector.create(RT.seq(obj))); } if (obj is IEnumerable ie) { return(PersistentVector.create1(ie)); } return(createOwning(RT.toArray(obj))); }
public static void CreateButton(PersistentVector vec) { ClojureDefinedUI.AddClojureButtons(vec); }
public TransientVector(PersistentVector v) : this(v._cnt, v._shift, EditableRoot(v._root), EditableTail(v._tail)) { }
public static void CreateDropdown(string label, Var var, PersistentVector keyvaluepairs, IFn func) { ClojureDefinedUI.AddClojureDropDownBox(label, var, keyvaluepairs, func); }
/// <summary> /// Constructs a lazily persistent vector. /// </summary> /// <param name="meta">The metadata to attach.</param> /// <param name="array">The array of values.</param> /// <param name="v">The accompanying persistent vector.</param> LazilyPersistentVector(IPersistentMap meta, object[] array, PersistentVector v) : base(meta) { _array = array; _v = v; }
public static PersistentVector create(ISeq items) { Object[] arr = new Object[32]; int i = 0; for (; items != null && i < 32; items = items.next()) arr[i++] = items.first(); if (items != null) { // >32, construct with array directly PersistentVector start = new PersistentVector(32, 5, EmptyNode, arr); TransientVector ret = (TransientVector)start.asTransient(); for (; items != null; items = items.next()) ret = (TransientVector)ret.conj(items.first()); return (PersistentVector)ret.persistent(); } else if (i == 32) { // exactly 32, skip copy return new PersistentVector(32, 5, EmptyNode, arr); } else { // <32, copy to minimum array and construct Object[] arr2 = new Object[i]; Array.Copy(arr, 0, arr2, 0, i); return new PersistentVector(i, 5, EmptyNode, arr2); } }
public static DataSeries AddNewCurrentDataSeries(PersistentVector initialPoints, string name) { return AddNewCurrentDataSeries(initialPoints, name, null); }
public static void CreateDropdownFn(string label, PersistentVector keyvaluepairs) { ClojureDefinedUI.AddClojureDropDownBoxFn(label, null, keyvaluepairs, null); }
public static DataSeries AddNewSeries(PersistentVector initialPoints) { return AddNewSeries(initialPoints, null, null); }