instruction
stringlengths
71
71.9k
Problem: Write a small archiving program that stores students' names along with the grade that they are in. In the end, you should be able to: Add a student's name to the roster for a grade. Get a list of all students enrolled in a grade. Get a sorted list of all students in all grades. Grades should sort as 1, ...
I have finished the first part of my project, i.e., getting a full working program. However, the performance is not too impressive. The function expectedCosts(state const &S) took around 96% of the total running time, so any performance increase in this function might be worthwhile. For profiling purpose I used a reas...
Last day I implemented the Hunt and Kill algorithm in JavaScript, using HTML5 without any libraries. I would like my code to be reviewed. How it works I start with a 2D array filled with walls (1-s), then I pick a random point in it, and mark it as visited. First, I get all unvisited neighbors of that specific cell, th...
I made a small Poker program with C but I believe I could've written it better. Full source on bitbucket.org int checkhand (struct Card_s * hand) { assert (hand) ; //struct Card_s *suithand = sorthand(hand, true); // Unnecessary struct Card_s *sorted = sorthand(hand, false); /* check for flushes */ ...
I was working on the last days with threads and I didn't want to use ugly methods like Abort(), etc. So I did a simple class which does use one of the most performant and better alternative to Abort(). The class is named as CThread.cs which would stand for CleanThread.cs. Class code: using System; using System.Collecti...
tl;dr The purpose of the code is to allow writing constexpr auto x = std::uint16_t { UINT16_MAX }; constexpr auto y = std::uint16_t { UINT16_MAX }; static_assert(multiply(x, y) == 1u, "broken math"); in a portable way that won't invoke undefined behavior. If that is enough for you to understand the problem at hand, ...
I have a list of candidates which looks like this: candidates = [ { 'name': 'John', 'rank': 13 }, { 'name': 'Joe', 'rank': 8 }, { 'name': 'Averell', 'rank': 5 }, { 'name': 'William', 'rank': 2 } ] What I want to do is semi-...
I have implemented a std::function-like class, that is optimized for storing lambdas, that never copies the stored function, that has a small buffer to store small functors, avoiding dynamic memory allocation. is designed to be sized to exact multiples of a cache line, because the functors will probably be accessed ...
I am a beginner playing around with Python and Tkinter. I wrote this program to draw random names given the students in my classes. I tried to follow PEP 8, but I was wondering if there are any stylistic problems here and also if there is any way to condense the code without affecting the working of the program (as I'v...
Please review my ini file parser (and potentially some general config file formats). The data structure used is a section, see below. Does that seem a good approach? I was wondering about the name. It will parse ini files ok, but unix config files are so variable that calling the class config might be over selling it...
I have the following code for a peak finding algorithm in Python 3.4.3. A peak is an element that is not smaller than its neighbors. def peak1d(array): '''This function recursively finds the peak in an array by dividing the array into 2 repeatedly and choosning sides. Complexity: O(log n)''' ...
I would like some feedback on my solution for the trip programming challenge. Please go through my code understanding that I am interested in interviewing for a dev position at some point and am also interested in competitive programming (I'm just getting started): ''' @author: Teererai This code is intended to calcul...
This is a function that is the building block of one wordpress plugin. I came up with this code after some search but i need to optimize it and get any info from more experienced guys. public static function afz_encrypt_decrypt( $action, $string ) { $output = false; $encrypt_method = "AES-256-CBC"; $secret...
I have a working Java implementation of Bloom Filter. These are the methods to addElement and check for an element. private void addElement(byte[] element) { if (null == element) { throw new NullPointerException(); } long hash1 = Integer.toUnsignedLong(Murmur3Hash.murmurhash3_x86_32(element, 0, ele...
I have tried solving Project Euler #54 in Python. Please see description here -> Description: The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five are Player 1's cards and the last five are Player 2's ...
I made a simple file-encryption utility application for a little school project. I'm really interested in cryptography, and tried my best while making it. Can you see it, and give me feedback? The input is always a FileInputStream (wrapped by a BufferedInputStream), and the output is a ByteBufferOutputStream, which wi...
I am a beginner in Python and PyGame and wrote a memory game. I think there are lot of things I could have done better. I am looking for some advice on how I can improve the design and refactoring of the code. # the imports import pygame import random from itertools import product from pygame.locals import * from pygam...
This code is supposed to implement RFC 3394 which also described in this PDF at page 11. Are there any weak places or formatting issues in attached source? Or maybe some places are not explicit enough? void wrap( const unsigned char *key, const unsigned char *plaintext, unsigned int plaintext_length, unsig...
How can this script be optimized? def processor(n): """Finding the factorial of a given number. """ if n == 0 or n == 1: return 1 product = 1 for i in range(1, n + 1): product *= i return str(n) + '! = ' + str(product) def guardian(): """Asking for a number and guarding the scri...
This recursive calls reverseList on each node of the linked list. When returned from the function call, it changes the next link to the previous node. public static Node reverseList(Node curNode , Node prevNode , Node reverseListHead) { //empty list if(curNode == null) { return null; } //nod...
I'm learning clojure ref types and was trying to make a robust counter generating function. Is there any error or improvement on the code? is there a simpler way? (I want the function to be thread-safe) (defn get-counter [] (let [a (agent 0)] (fn [] (let [p (promise)] (send a (fn [old] ...
This is a second rev of this SE Question. How can I add more validation to this .ico file downloader? It works but I need a way to check the integrity of each step: Check Default location ( checked length is greater than 20 ) ( broken for test.com ... why ? Check Google API ( validation already added ) Scrape page for...
Abstract For the past week I have been looking at taking advantage of the .NET 4.5 improvements to code signing and XML signing to produce a licensing subsystem I can use to license my own products. I now have the thing working pretty well, and I am looking for input as to how it could be improved, or what security iss...
The code performs bubble sort on the basis if any swaps has been performed in the iteration. I made it sort of independent of number of iterations as in any conventional bubble sorting code. I went on pretty much with what I understood from the cs50 class. This mechanism looks more intuitive to me. What improvements I ...
This is an attempt at a fast "document distance" implementation in C++. For reference, I found this problem in MIT's OpenCourseware 6.006 algorithms course. A quick look at the callgrind output shows that my performance killers are, in order: the transfrom call in formatToken Constructing inputString in wordOccurence...
I would like to get feedback on the solution and a question regarding Big O. I am first converting each character in the string into the array and that would be O(n) then i am sorting the array O(n log n) and then I join back the array. Not sure if that is O(n). After i get the sorted string I would retrieve the NSAr...
I made a simple state wrapper for a react project I am working on, so I can keep my state at the top component but reason about it at a lower class level. The example below is very simple, but it works and provides enough of an example of what StateWrapper does, obviously i am using it in reality with a much more compl...
I am a relatively new Python programmer and made a simple Pig Latin to English translator and vice versa. I would just like it if someone reviewed my code and see if anything can be done to make it more Pythonic or efficient. from time import sleep def main(): to_piglatin = input("Do you want to translate somethin...
It's been some time since I wrote something in C. I am looking for some advices related to my code in terms of coding style, bad/wrong logic, optimization (performance) and good practices. The code speaks for itself, but if there are any questions, I'll add some comments to make it clearer. #include <stdio.h> #include ...
I have to write a function which turns a string with the words separated by dashes ( - ) into a sentence using camel case notation. I've had the following idea for an implemenation using the reduce-method of Array: // -------- THE ACTUAL FUNCTION ------------------------- /** * Converts a string with dashes as wor...
The TESSER - Finding the Tesserect problem is tagged as a problem to be solved by Knuth-Morris-Pratt (KMP) algorithm. I'm using KMP, but am still getting time-limit-exceeded. Task Each of T test cases (1 ≤ T ≤ 105) consists of three lines: A single integer N (2 ≤ N ≤ 105) denoting the number of data points. N integers...
The main idea behind this class is to create a wrapper for commonly used Database classes. I'm new to SOLID principles and I'm trying to implement them in this library. Does this code adhere to SOLID principles? //This is the opens the SQL Connection and is placed in DbConnectionSetup.cs public interface IConnecti...
here is my code, it works but after few iterations it slows down and stop without any error, I'm looking for a more efficient solution. #include <iostream> #include <vector> #include <algorithm> #include "SafeQueue.h" using namespace std; const int DATA_MAG = 256; struct Frame { int num; char type;...
If I have an array of numbers like this: 1 3 4 6 7 1 2 2 4 5 9 5 7 1 2 3 5 Is there a quick way to take all of the unique numbers and arrange them into a single column, like this? 1 2 3 4 5 6 7 9 The approach I have works, but takes a very long time for large matrix: Sub Test1 Call RecordArrange Call Re...
I'm writing a program to read two files supplied as arguments in the command line, convert them from list to char[][], and display their contents to the user. I'm trying to practice exception-handling and javadocs, so I'm not interested in using a library. Also, this will be part of a larger program, hence the conversi...
Apart from general JavaScript knowledge, this snippets requires someone who knows how to properly use Google Analytics API. To log errors on my site, I use this code: try { window.addEventListener("error", function(e) { var file = e.filename.substr(e.filename.lastIndexOf("/")+1); // for some reason, filename ...
I try to use complex numbers in a lua program. I need to parse a table of complex numbers printing side by side the name of the complex number and its value. Can't get through it : I don't ask how the library works. require "complex" a = complex.new (0,1) b = complex.new (7,1) c = complex.new (1,6.4) t = {a="a", ...
Can you review my F# code and point out some insights about it? What I want to know, in order of relevance: Avoid so much common code between DFA and NFA. I want to make something more generic, there is much code in common there. Make it more F# idiomatic Performance is not a concern. Readability is. module DFA = ...
I've been building an IDE using C# and only the console. To get keyboard input in real time (as opposed to a read–eval–print loop,) I have the following method to get keyboard input: public static ConsoleKeyInfo[] GetInput() { // A list of characters List<ConsoleKeyInfo> input = new List<ConsoleKeyInfo>(); ...
Please provide constructive criticism for this TinyMCE plugin which allows the user to save the content, or cancel and go back to the original. JS Bin <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Testing</title> <link href="//aj...
The purpose of the code is to store arbitrary number of types. The type can be extracted from it using Extract template, which uses template recursion to get the needed type. There will be compilation error if user will try to get out of bounds. I think it supports both fully defined types and only declared types. In ...
This basically creates a namespace for Storage among other things. I'm looking for feedback on the structure of the code. /******************************************************************************************************************(120) ** Storage ** - Dependencies - None ** - Basically creates a namespace for S...
I'm doing a college assignment with jQuery Mobile and JSON. Best practice with jQuery mobile is my main concern. My html starts off with a main 'page' (data-role="page") inside a div with id="all-pages". I use jQuery's .getJSON method to connect to a local JSON file called profiles.json. profiles.json contains an arra...
I'm working on a Wall-runner reaction based game. Whilst I know my way around a lot of the features Unity provides, I'm still in the beginner phase when it comes to working with several classes and functions simultaneously. I have currently got the two following classes that work together: Obstacle class public class O...
I have a regular expression that match the string that contains the word "duration", followed by a < or > operator and then a number. Here is the expression: duration\s*(<|>)\s*([0-9]+) Is there any way I can make this expression better?
I'm trying to re-implement the C stdlib function qsort using a median of 3 quicksort. void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*)) This is my first major project in C, and I'd like to know how my style looks and what techniques I might be missing out on. Thanks for the h...
I have made a simple tic tac toe game and need help tweaking it to fit the bill of object oriented design. Any suggestions most welcome. I basically want it safer, and more "best practice-like" It is a game consisting of four classes, and I'm pretty happy with it as I am new to programming, but maybe it is worthless se...
The app: Creates CountDownTimers and displays them in a simple layout. The user can choose how long the timer should be through SharedPreferences and a settings activity. Each timer has a preparation period before it actually starts. The problem: I'm not sure how, but I feel like the code is messy and needs to be clean...
I am currently implementing the Ace-editor embeddable code editor. In to my application. I use a div with a certain class(example: editor_js) to render the editor the div also gets a data attribute (data-key) corresponding with the name (example: Site[tagmanager]) of a textarea. The session from the div get stored in ...
I would like to ask more experienced developers to review my code, it's my first app, self-made, I know there is a lot to improve, it would be great if you could just point the main errors. I'm aware that my implementation is not universal, but I couldnt get past it. My edit option with usage of DTO seems shi*y to me,...
Given a string, S, of length N that is indexed from 0 to N−1, I want to print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line: Hacker -> Hce akr My code works, but I feel it could have been done more elegantly and maybe in a single stream instead of in two... Any ideas how to...
All I have built an MVC WinForms application where Views are blind and deaf of their controllers. To facilitate this I have used Ninject as my Dependency Injection (DI) Inversion of Control (IoC) container. I have a question regarding my design/architecture of the way I handle showing dialogs (remembering I want full t...
I have the following VBA code, which works perfectly well to calculate "q" However, the code is very slow and that is due to the large number of q's being calculated (roughly 7.2m q's are being calculated). So I thought the best way to proceed is to try store the calculated q values in an array and then dump them into ...
I'm creating an application to get data cross domain all the line of code seem work as well but I'm not much understand about performance with my code process with the real server and real action because sometime there are a lot of case will happen when I fetch those data so I want to make a method to get those errors ...
I have a simple query using query builder of VS2012 C# which updates the database in my winforms application. The database has 216 entries so far and it's taking a lifetime to update the database. How to reduce the time? Should I make more queries for each column or is there something else? UPDATE StudentInfo SET ...
I'm a complete beginner to Python, and wanted to get some feedback on my first app. I tried to make a clone of the 'evolution of text' app found on the Using Python website. Enter some text, and watch the program 'evolve' the answer. The program just prints a load of random text, but keeps the correct bits each time. ...
I have a Pi with a camera module that I control with Python. I created a web server with web.py that allows me to make HTTP requests to the PI to retrieve an image. There are two optional parameters to specify the width and height of the image. The code looks like this (imports omitted): urls = ( '/capture', 'Captu...
I am developing a plugin for a GIS (Geographic Information Systems) software which uses Python. I have been using Python for over a year (on-off) and have the following code which works. It basically reads the names of files loaded into the GIS software to compose a QGIS expression for every group of files. Finally it ...
This code get a list<dynamic> from a repository class using Dapper. I need to bind this list to a ComboBox. The only way I can get this to work is by using a simple class (ComboBoxItem in my case) and than use that to do the binding. UI.cs var mRep= new MaterialRepository(); comboBox1.Items.Clear(); foreach (var item ...
On Sheet 1 is a legend that contains unique values in Column A every ten rows. To the right of each value in the next five columns over are a series of color filled cells that extend down ten rows to the start of the next unique value. The color fill of each 5x10 area is what I want transferred to the dataset sheet. Th...
Here, i build one form validation script in php using understanding SOLID concept. My question is the way i coded my code is true way for OO concept ? Use of abstract class and the extend it, is that true way ? can i strongly use interface for this functionality ? i use namespace but i can't include using use keyword ...
I am working with a TreeView (default control from .Net Framework) that displays hierachical data. Data are bound to the view using MVVM pattern with the HierarchicalDataTemplate. <HierarchicalDataTemplate DataType="{x:Type models:TreeItemViewModel}" ItemsSource="{Binding Children, Mode=OneWay}"> <TextBlock Text="{...
I've done a lot of reworking to this main file recently, in regards to using a new speech recognition engine and integrating the last reviews suggestions. My question before is going to be phrased very similarly to how it was previously. How Khronos Works The process starts by recording a .wav file with LibSndFile an...
This algorithm sorts a list of Individuals, each with two fitness values, into what's called non-dominated fronts. A non-dominated front is a set of individuals where none of the individuals dominate each other. An individual is said to dominate another if is equal or lower (<=) for all fitness values and lower (<) in ...
I am trying to solve an SPOJ problem: print all prime numbers in a given range (as large as \$10^9\$). I have used the Sieve of Eratosthenes algorithm. But it is still slow when input is in range of \$10^4\$. import math no_of_cases = int(input()) for i in range(no_of_cases): x = input().split(" ") a = int(x[0...
This describes type util::any<std::size_t size, std::size_t align> - an implementation of std::any with a static size/no dynamic allocation. It closely follows the standard's specification for std::any. A discriminated type that can contain values of different types but does not attempt conversion between them, i.e....
How can I make this little program work a little faster? The task is to calculate the max difference between any 2 numbers from an array of numbers. Target time is 1 sec, now it works in 1.1 sec. I've tried BufferedReader, PrintWriter and nested loops (instead of Arrays.sort). import java.util.Arrays; import java.util....
Anyone have any tips on how to divide my code up into classes? This seems to work from me but would prefer to have it divided up into one or two separate classes if possible. static Scanner sc = new Scanner(System.in); public static void main(String[] args) { System.out.println(); System.out.println(); String prompt ...
When users log in to our website, we store some information in a session to retrieve it across the site. We created a few wrappers to help with data retrieval/storage to lessen duplication of code. I'm trying to redesign it as I don't like how the UserModel is written. I believe it's dangerous with the static propertie...
I am having a Python list of lists, that I get as an output of python-igraph (membership to clusters). The integers represent an association of a vertex to a certain cluster at a certain subgraph. I would like to organise this list in a way that the biggest cluster in the whole (unconnected) graph is getting the lowest...
I have written Python code which works absolutely fine but I am looking for other ways to do this: import itertools def permutation(word): for i in range(len(word)+1): perms=list(itertools.permutations(word)) for i in perms: j=(''.join(i)) j=j.casefold() k=reversed(j) ...
This function serves me as a testing-utility to check if the result is really numeric and sometimes as input-validation if there are a lot of operations before I would find out (with an Exception) if it's not-numerical. But I feel like the .dtype.kind in ... is too complex. I've written this function a while back and ...
I'd like to restrict user input in a form to a decimal with max two numbers before and 4 after decimal point. Valid values would be: 50 0.1 1.23 4.5678 12.943 I'm currently doing the following: $(function() { $('input').on('input', function() { this.value = this.value .replace(/[^\d.]/g, '') ...
I've recently created my own 2-player chess game, no AI... at least for now. I do plan to do that in the future, so one of my concerns is if the code is flexible enough to just use the same classes in all the different modes so I can avoid rewriting the same code over and over again. I've tried to explain most of the l...
(Part 1 here) I've recently created my own 2-player chess game, no AI... at least for now. I do plan to do that in the future, so one of my concerns is if the code is flexible enough to just use the same classes in all the different modes so I can avoid rewriting the same code over and over again. Resuming with the o...
I've been trying to learn Python and I've managed to muddle through enough to put together a simple Hangman game (albeit with a few bugs and game features missing!). However, I feel like I haven't done a very good job as I seem to have repeated a lot of code. Does anyone have any simple tips for how I could improve the...
I'm trying to implement a search bar in which the user sends a search term and the search bar displays the results. I have a naive solution which separates the original list into three sublists: a list with all the exact matches, a list with all the phrases containing the search term and a list with all the phrases tha...
I have been told for my code below i need to "Improve and optimise the codebase of the application to reflect modern and best coding practices". Can anyone help me in doing this? As I know the service worker code can't be optimised so I am not sure what other code I can change/improve for best coding practices. The HTM...
I'm trying to recreate strstr in c, my code works but I think it is too long, and it needs some improvement. #include <stdlib.h> static int find_str_indx(char *str, int index, char *str_to_find) { int i; int temp; int found_index; while (str[index] != '\0') { if (str[index] == *str_to...
This program reads all files in a folder and subfolders line by line, converts them in a supported character set, replaces all unsupported characters and inserts them in a SQL database. My idea was to insert all CSV files. It works fine indeed but it takes a long time to insert all the data, especially for files that a...
I've built a Search Engine class for a website that permits to search companies in base of their locations and their categories (companies pay a plan to be found in the places that they will). In the constructor you can pass an index array cointaining the parameters or you can set them later with setters. All parameter...
I am aware this problem has been asked before but in java e.g Printing longest sequence of zeroes. This is a similar problem but in C#. A brief explanation of the problem is to find the longest sequence of zeroes in a binary representation of an Integer. For instance, the Integer 529 in binary gives 1000010001 and th...
I wrote this script to automatically install the relevant version of MacPorts. It's supposed to be used in a fashion similar to the official installer for HomeBrew. FYI: The real reason that I decided to write this script is; I'm not all that confident in every aspect of my bash scripting abilities and I needed a proj...
I've created following code which works just fine: GraphBar1.GetComponent<RectTransform> ().sizeDelta = new Vector2 (50, oScript.reactionTimeArray [0] * 1000); GraphBar2.GetComponent<RectTransform> ().sizeDelta = new Vector2 (50, oScript.reactionTimeArray [1] * 1000); GraphBar3.GetComponent<RectTransform> ().sizeDelta ...
I have a user-editable dictionary of content used to fill in a string.Template and I wanted to allow the user to fill the same template with several values at once. Using only values, itertools.product would be enough for my needs but I needed dictionaries to fill in a template. I also wanted users to be able to enter ...
I wrote a method which sorts an array of hashes by given hash keys. The method should put nil values at the end. def sort(records, *attrs) records.sort do |a,b| result = 0 attrs.each do |attr| unless a[attr] == b[attr] result = if a[attr].nil? 1 elsif b[attr]....
I’m pretty new to programming and python in particular. This is a simple ICMP/TCP scanner that dumps output to a terminal and/or csv file. My goal was to make a daemon that could do simple scanning without requiring any special imports. It is my first attempt at writing something that would be useful and that I might e...
I am doing a college project and I would like to write my jQuery code following best practices. The project involves using the jQuery .getJSON method to retrieve information from a json file. I have left out parts of the code so that it is more readable (however this is indicated in the comments). The code shows two ap...
Problem: Write a program that, given an age in seconds, calculates how old someone is in terms of a given planet's solar years. Earth: orbital period 365.25 Earth days, or 31557600 seconds Mercury: orbital period 0.2408467 Earth years Venus: orbital period 0.61519726 Earth years Mars: orbital period 1.8808158 Earth...
I've been working on an iOS IOT client app which uses MQTT. After some reading I decided to go with CocoaMQTT. I have only been programming in swift/iOS for about 2 weeks now, so I thought I should have my base code reviewed here before continuing any further. The idea is to have most of the MQTT connection handling ...
Inspired by this question and therefore this one I decided that clearly the best most readable way to solve this is with Regular Expressions. A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, num...
I'm working on building understanding of data structures in general, and specifically linked lists in this example. I'm also trying to increase my ability with templates. In cross-referencing dozens of examples, I've blended what I've seen into the following node template "Node.h" file: /* 11 May 2015 VS 2015 Communit...
There are a number of topics pertaining to entity change tracking. All the ones I've seen involve either 1) notifying when a property has changed or 2) merely determining whether or not an entity is dirty. My goal is quite different. I wrote a mini-repository framework that generates SQL for inserts, selects, updates...
I have categories and subcategories in my view. The code looks like this <ul> <% Category.roots.each do |category| %> <li class="col-md-2"> <a href="#"><%= category.name %></a> <% if !category.children.empty? %> <ul> <%= category.decorate.draw_tree %> </ul> <% end %> </li> <% end %> </...
For Khronos, I've had to develop these utility functions to help me deal with storing the .wav files. However, they could also be used in a variety of applications. A description of what the three functions do are given in the header documentation comments. util.h: #ifndef UTIL_H #define UTIL_H /** * @return the te...
So I needed to write a function that takes a string and returns a javascript object with vowels and consonants properties that maps to the number of vowels and consonants in the string function getCount(words) { let answer = {vowels: 0, consonants: 0}; if( typeof words !== 'string') { return answer } let vowel ...
Unfortunately due to my job I will have to leave out some of the information that is created by this generator, however I will be replacing it with another string of information. I have created an email generator for work, that will user a template and add the information provided into the email, I would like some crit...
I wrote this in order to solve the fractional knapsack problem. Any feedback is appreciated. def get_optimal_value(capacity, weights, values): value = 0. if sum(weights) <= capacity: return sum(values) if len(weights) == 1: value = values[0]/float(weights[0])*capacity densities = [(v/flo...
This code works, but I want to refine it: # ======================= # Dir Walk # # This will recursively walk a directory # ======================== function dirwalk(path::AbstractString, fn::Function) content = readdir(path) for c in content p = joinpath(path, c) if isdir(p) dirwalk(p, fn) elsei...
I recently implemented Linked List on my own. I did not use generics as I am still learning. How can I improve it: package datastructures; class LinkedList { Node head = null; Node tail = null; int size = 0; public void add(int data) { Node n = new Node(); n.setElement(data); ...