Search Results

Search found 3788 results on 152 pages for 'pure equal'.

Page 11/152 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Are lambda expressions/delegates in C# "pure", or can they be?

    - by Bob
    I recently asked about functional programs having no side effects, and learned what this means for making parallelized tasks trivial. Specifically, that "pure" functions make this trivial as they have no side effects. I've also recently been looking into LINQ and lambda expressions as I've run across examples many times here on StackOverflow involving enumeration. That got me to wondering if parallelizing an enumeration or loop can be "easier" in C# now. Are lambda expressions "pure" enough to pull off trivial parallelizing? Maybe it depends on what you're doing with the expression, but can they be pure enough? Would something like this be theoretically possible/trivial in C#?: Break the loop into chunks Run a thread to loop through each chunk Run a function that does something with the value from the current loop position of each thread For instance, say I had a bunch of objects in a game loop (as I am developing a game and was thinking about the possibility of multiple threads) and had to do something with each of them every frame, would the above be trivial to pull off? Looking at IEnumerable it seems it only keeps track of the current position, so I'm not sure I could use the normal generic collections to break the enumeration into "chunks". Sorry about this question. I used bullets above instead of pseudo-code because I don't even know enough to write pseudo-code off the top of my head. My .NET knowledge has been purely simple business stuff and I'm new to delegates and threads, etc. I mainly want to know if the above approach is good for pursuing, and if delegates/lambdas don't have to be worried about when it comes to their parallelization.

    Read the article

  • Why is FLT_MIN equal to zero on OS X?

    - by Nick Forge
    limits.h specifies limits for non-floating point math types, e.g. INT_MIN and INT_MAX. These values are the most negative and most positive values that you can represent using an int. In float.h, there are definitions for FLT_MIN and FLT_MAX. If you do the following: NSLog(@"%f %f", FLT_MIN, FLT_MAX); You get the following output: FLT_MIN = 0.000000, FLT_MAX = 340282346638528859811704183484516925440.000000 FLT_MAX is equal to a really large number, as you would expect, but why does FLT_MIN equal zero?

    Read the article

  • How to make two different files (with their contents) equal using command in linux shell?

    - by user2617138
    How to make two different files (their contents) equal using terminal in Linux? Suppose i have a file A in which the content is Hello world and i have a file B in which the content is Hello worlds. Now we find the difference between the 2 files using the diff or sdiff utility. Now i want to append the contents of the 2 different files into a single file or make the two different files (their contents) equal using terminal or any other utility.

    Read the article

  • Are web application usability issues equal to website usability issues?

    - by Kor
    I've been reading two books about web usability issues and tests (Rocket Surgery Made Easy¹ and Prioritizing Web Usability²) and they claim some strategies and typical problems about website usability and how to lead them. However, I want to do a web application, and I think I lost track of what I am trying to solve. These two books claim to work with raw websites (e-commerce, business sites, even intranet), but I'm not sure if everything about web usability is applicable to web application usability. They sure talk about always having available (and usable) the Back button, to focus on short information rather than big amounts of text, etc., but they could be inaccurate in deeper problems that may be easier (or just skippable) in regular websites. Has anybody some experience in this field and could tell me if both web applications and websites share their usability issues? Thanks in advance Edit: Quoting Wikipedia, a website is a collection of related web pages containing images, videos or other digital assets, and a web application is an application that is accessed over a network such as the Internet or an intranet. To sum up, both shows/lets you search/produce information but websites are "simple" in interaction and keep the classics of websites (one-click actions) and the other one is closer to desktop applications in the meaning of their uses and ways of interaction (double click, modal windows, asynchronous calls [to keep you in the same "environment" instead of reloading it] etc.). I don't know if this clarifies the difference. Edit 2: Quoting @Victor and myself, a website is anything running in your browser, but a web application is somewhat running in your browser that could be running in your desktop, with similar behaviors and features. Gmail is a web application that could replace Outlook. GDocs could replace Office. Grooveshark could replace your music player, etc.

    Read the article

  • When to decide to introduce interfaces (pure abstract base classes) in C++?

    - by Honza Brabec
    Assume that you are developing a functionality and are 90% sure that the implementation class will stay alone. If I was in this position in Java I would probably not use the interface right now to keep the things simple. In Java it is easy to refactor the code and extract the interface later. In C++ the refactoring is not always so easy. It may require replacing values with smart pointers (because of the introduction of polymorphism) and other non-trivial tasks. On the other hand I don't much like the idea of introducing virtual calls when I am 90% sure they won't be needed. After all speed is one of the reasons to prefer C++ over simpler languages.

    Read the article

  • What to learn for a pure practical developer to get better?

    - by ChrisRamakers
    I'm a self taught developer that currently has more than enough experience to hold up against my colleagues waving with their degrees, yet I feel that I'm lacking some important skills to advance further into being a senior level professional in a leading role. More specific in the engineering, planning and designing aspect of software. I've touched the surface of UML, ERM/ERD, have experienced both waterfall and scrum projectmanagement, ... yet I feel there is something missing as every time I start on a new project I don't know where to begin. Should I start diagramming and how? should I start writing an xx page document describing the project on a technical level first, should I dive head first into writing the first tests and code or pseudo-code? I would like to know what, in my case, would be the best way forward, to learn how I can tackle this problem in the future and get better at leading and starting a project. There is not much i don't know about my technical tools and languages but when it gets abstract i'm in trouble.

    Read the article

  • Architecting persistence (and other internal systems). Interfaces, composition, pure inheritance or centralization?

    - by Vandell
    Suppose that you need to implement persistence, I think that you're generally limited to four options (correct me if I'm wrong, please) Each persistant class: Should implement an interface (IPersistent) Contains a 'persist-me' object that is a specialized object (or class) that's made only to be used the class that contains it. Inherit from Persistent (a base class) Or you can create a gigantic class (or package) called Database and make your persistence logic there. What are the advantages and problems that can come from each of one? In a small (5kloc) and algorithmically (or organisationally) simple app what is probably the best option?

    Read the article

  • jQuery how to add class to a parent div which has a 3rd level child div with a specific class name.

    - by Vikram
    Hello friends I have an issue adding a special class to a couple of my divs. My layout is like this. <div class="container"> <div class="grid-6 push-3 equal" style="height: 999px;"> <div class="block"> <div id="mainbody"> <!-- Body content here --> </div> </div> </div> <div class="grid-2 equal" style="height: 999px;"> <div class="block"> <div id="sidebar-a"> <!-- Sidebar-a content here --> </div> </div> </div> <div class="grid-2 equal" style="height: 999px;"> <div class="block"> <div id="sidebar-b"> <!-- Sidebar-b content here --> </div> </div> </div> <div class="grid-2 equal" style="height: 999px;"> <div class="block"> <div id="sidebar-b"> <!-- Sidebar-c content here --> </div> </div> </div> </div> I want to add a different background color to each of my sidebars via CSS and when I code like: #mainbody { background : #fff; } #sidebar-a { background : #eee; } #sidebar-b { background : #ddd; } #sidebar-c { background : #ccc; } It is applying the background only to that specific class but that specific class is not of equal height. I actually need to apply to this <div class="grid-2 equal" style="height: 999px;"> div. Now the issue is that in this <div class="grid-6 push-3 equal" style="height: 999px;"> and class="grid-2 equal" style="height: 999px;"> the class names grid-6 and grid-2 are generated dynamically by my PHP of 960 Grid System and also the style="height: 999px; is generated by a jQuery script for Equal-Columns. What I want is to add a unique class name like this...... Look for a div with a class of .equal which has a child div with a class of .block and which further has a child div with an ID of sidebar-a. IF TRUE then add a class of .sidebar-a to the maindiv which has a class of .equal So that the result looks like this: <div class="grid-6 equal push-3 mainbody" style="height: 999px;"> <div class="grid-2 equal sidebar-a" style="height: 999px;"> <div class="grid-2 equal sidebar-b" style="height: 999px;"> <div class="grid-2 equal sidebar-c" style="height: 999px;"> Then I'll be able to style it like this: .mainbody { background : #fff; } .sidebar-a { background : #eee; } .sidebar-b { background : #ddd; } .sidebar-c { background : #ccc; } Hence I thought since I am anyway using jQuery in my Template, why not use it to deal with this issue. Please feel free to suggest a better way if you have something else in mind.

    Read the article

  • Is there a way to extracting semantic informations from PDF? (converting PDF to pure XHTML)

    - by Eonil
    Hi. I'm finding a way to extract semantic structural informations (like title, heading, paragraph or lists) from PDF. Because I want to get a pure structural data from PDF. Finally, I want to create an pure XHTML from the PDF. With only structural informations. No design or layout. I know, PDF can be created without any structural information. I don't consider those PDFs. Only regularly well-structured PDFs are considered. I'm new to PDF. So I don't know it offers regular semantic structure or not. If it exists, it's library will offer it. So I want to know whether PDF spec has those information, and best way to get those information if exists.

    Read the article

  • Pure Java open-source libraries for portfolio selection (= constrained, non-linear optimization)?

    - by __roland__
    Does anyone know or has experience with a pure Java library to select portfolios or do some similar kinds of quadratic programming with constraints? There seems to be a lot of tools, as already discussed elsewhere - but what I would like to use is a pure Java implementation. Since I want to call the library from within another open-source software with a BSD-ish license I would prefer LGPL over GPL. Any help is appreciated. If you don't know such libraries, which is the most simple algorithm you would suggest to implement? It has to cope with an inequality constraint (all x_i = 0) and an equality constraint (sum of all x_i = 1).

    Read the article

  • What's the best example of pure show-off code you've seen?

    - by Damovisa
    Let's face it, programmers can be show-offs. I've seen a lot of code that was only done a particular way to prove how smart the person who wrote it was. What's the best example of pure show-off code you've seen (or been responsible for) in your time? For me, it'd have to be the guy who wrote FizzBuzz in one line on a whiteboard during a programming interview. Not really that impressive in the scheme of things, but completely unnecessary and pure, "look-what-I-can-do". I've lost the original code, but I think it was something like this (linebreaks for readability): Enumerable.Range(1,100).ToList().ForEach( n => Console.WriteLine( (n%3==0) ? (n%5==0) ? "FizzBuzz" : "Fizz" : (n%5==0) ? "Buzz" : n ) );

    Read the article

  • How to change the app name in OSX menubar in a pure-Python application bundle?

    - by gyim
    I am trying to create a pure-Python application bundle for a wxPython app. I created the .app directory with the files described in Apple docs, with an Info.plist file etc. The only difference between a "normal" app and this bundle is that the entry point (CFBundleExecutable) is a script which starts with the following line: #!/usr/bin/env python2.5 Everything works fine except that the application name in the OSX menubar is still "Python" although I have set the CFBundleName in Info.plist (I copied the result of py2app, actually). The full Info.plist can be viewed here: http://tinyurl.com/32qgpjt How can I change this? I have read everywhere that the menubar name is only determined by CFBundleName. How is it possible that the Python interpreter can change this in runtime? Note: I was using py2app before, but the result was too large (50 MB instead of the current 100KB) and it was not even portable between Leopard and Snow Leopard... so it seems to be much easier to create a pure-Python app bundle "by hand" than transforming the output of py2app.

    Read the article

  • Is there any LAME c++ wraper\simplifier (working on Linux Mac and Win from pure code)?

    - by Ole Jak
    So I want to create simple pcm to mp3 C++ project. I want it to use LAME. I love LAME but It is realy biiig. so I need some kind of OpenSource working from pure code with pure lame code workflow simplifier. So to say I give it File with PCM and DEST file. Call something like LameSimple.ToMP3(file with PCM, File with MP3 , 44100, 16, MP3, VBR); ore such thing in 4 - 5 lines (examples ofcourse should exist) and I have vhat I needed It should be light, simple, powerfool, opensource, crossplatform. Is there any thing like this?!?

    Read the article

  • How do I implement a remove by index method for a singly linked list in Java?

    - by Lars Flyger
    Hi, I'm a student in a programming class, and I need some help with this code I've written. So far I've written an entire linked list class (seen below), yet for some reason the "removeByIndex" method won't work. I can't seem to figure out why, the logic seems sound to me. Is there some problem I don't know about? public class List<T> { //private sub-class Link private class Link { private T value; private Link next; //constructors of Link: public Link (T val) { this.value = val; this.next = null; } public Link (T val, Link next) { this.value = val; this.next = next; } @SuppressWarnings("unused") public T getValue() { return value; } } private static final Exception NoSuchElementException = null; private static final Exception IndexOutOfBoundsException = null; private Link chain = null; //constructors of List: public List() { this.chain = null; } //methods of List: /** * Preconditions: none * Postconditions: returns true if list is empty */ public boolean isEmpty() { return this.chain == null; } /** * Preconditions: none * Postconditions: A new Link is added via add-aux * @param element */ public void add(T element) { this.add_aux(element, this.chain); } /** * Preconditions: none * Postconditions: A new Link is added to the current chain * @param element * @param chain */ private void add_aux(T element, Link chain) { if (chain == null) { //if chain is null set chain to a new Link with a value of //element this.chain = new Link(element); } else if (chain.next != null) { //if chain.next is not null, go to next item in chain and //try //to add element add_aux(element, chain.next); } else { //if chain.next is null, set chain.next equal to a new Link //with value of element. chain.next = new Link(element); } } /** * Preconditions: none * Postconditions: returns the link at the defined index via nthlink_aux * @param index * @return */ private Link nthLink (int index) { return nthLink_aux(index, this.chain); } /** * Preconditions: none * Postconditions: returns the link at the defined index in the specified *chain * @param i * @param c * @return */ private Link nthLink_aux (int i, Link c) { if (i == 0) { return c; } else return nthLink_aux(i-1, c.next); } /** * Preconditions: the specified element is present in the list * Postconditions: the specified element is removed from the list * @param element * @throws Exception */ public void removeElement(T element) throws Exception { if (chain == null) { throw NoSuchElementException; } //while chain's next is not null and the value of chain.next is not //equal to element, //set chain equal to chain.next //use this iteration to go through the linked list. else while ((chain.next != null) && !(chain.next.value.equals(element))){ Link testlink = chain.next; if (testlink.next.value.equals(element)) { //if chain.next is equal to element, bypass the //element. chain.next.next = chain.next.next.next; } else if (testlink.next == null) { throw NoSuchElementException; } } } /** * Preconditions: none * Postsconditions: the Link at the specified index is removed * @param index * @throws Exception */ public void removeByIndex(int index) throws Exception { if (index == 0) { //if index is 0, set chain equal to chain.next chain = chain.next; } else if (index > 0) { Link target = nthLink(index); while (target != null) { if (target.next != null) { target = target.next; } //if target.next is null, set target to null else { target = null; } } return; } else throw IndexOutOfBoundsException; } /** * Preconditions: none * Postconditions: the specified link's value is printed * @param link */ public void printLink (Link link) { if(link != null) { System.out.println(link.value.toString()); } } /** * Preconditions: none * Postconditions: all of the links' values in the list are printed. */ public void print() { //copy chain to a new variable Link head = this.chain; //while head is not null while (!(head == null)) { //print the current link this.printLink(head); //set head equal to the next link head = head.next; } } /** * Preconditions: none * Postconditions: The chain is set to null */ public void clear() { this.chain = null; } /** * Preconditions: none * Postconditions: Places the defined link at the defined index of the list * @param index * @param val */ public void splice(int index, T val) { //create a new link with value equal to val Link spliced = new Link(val); if (index <= 0) { //copy chain Link copy = chain; //set chain equal to spliced chain = spliced; //set chain.next equal to copy chain.next = copy; } else if (index > 0) { //create a target link equal to the link before the index Link target = nthLink(index - 1); //set the target's next equal to a new link with a next //equal to the target's old next target.next = new Link(val, target.next); } } /** * Preconditions: none * Postconditions: Check to see if element is in the list, returns true * if it is and false if it isn't * @param element * @return */ public boolean Search(T element) { if (chain == null) { //return false if chain is null return false; } //while chain's next is not null and the value of chain.next is not //equal to element, //set chain equal to chain.next //use this iteration to go through the linked list. else while ((chain.next != null) && !(chain.next.value.equals(element))) { Link testlink = chain.next; if (testlink.next.value.equals(element)) { //if chain.next is equal to element, return true return true; } else if (testlink.next == null) { return false; } } return false; } /** * Preconditions: none * Postconditions: order of the links in the list is reversed. */ public void reverse() { //copy chain Link current = chain; //set chain equal to null chain = null; while (current != null) { Link save = current; current = current.next; save.next = chain; chain = save; } } }'

    Read the article

  • =~ (equal-sign tilde) and m" ... " in .htaccess directive [closed]

    - by Lèse majesté
    I saw this bit of code on an old forum post: SSLRequire %{HTTP_HOST} =~ m"\.secure\.powweb\.com" And I was just wondering what the =~ and m" ... " meant. I've been searching online and in the Apache documentation for any mention of the equal-sign tilde operator, but I've found no mention of it. I know that some directives can take a tilde to use a regular expression, but I've never seen the m" ... " form used before. What exactly is that m" ... " for? Where else would you see this form?

    Read the article

  • 2D Rectangle Collision Response with Multiple Rectangles

    - by Justin Skiles
    Similar to: Collision rectangle response I have a level made up of tiles where the edges of the level are made up of collidable rectangles. The player's collision box is represented by a rectangle as well. The player can move in 8 directions. The player's velocity is equal in X and Y directions and constant. Each update, I am checking the player's collision against all tiles that are a certain distance away. When the player collides with a rectangle, I am finding the intersection depth and resolving along the most shallow axis followed by the other axis. This resolution happens for both axes simultaneously. See below for two examples of situations where I am having trouble. Moving up-left against the left wall In the scenario below, the player is colliding with two tiles. The tile intersection depth is equal on both axes for the top tile and more shallow in the X axis for the middle tile. Because the player is moving up the wall, the player should slide in an upward direction along the wall. This works properly as long as the rectangle with the more shallow depth is evaluated first. If the equal intersection depth rectangle is evaluated first, there is a chance the player becomes stuck. Moving up-left against the top wall Here is an identical scenario with the exception that the collision is with the top wall. The same problem occurs at the corners when intersection depth is equal for both axes. I guess my overall question is: How can I ensure that collision response occurs on tiles that have non-equal intersection depth before tiles that have equal intersection depth in order to get around the weirdness that occurs at these corners. Sean's answer in the linked question was good, but his solution required having different velocity components in a certain direction. My situation has equal velocities, so there's no good way to tell which direction to resolve at corners. I hope I have made my explanation clear.

    Read the article

  • Suggestions for entering mobile development -- pure iPhone SDK, Andorid SDK. Mono Touch or Titanium?

    - by Tom Cabanski
    I am entering mobile development. I have been working primarily in .NET since 1.0 came out in beta. Before that, I was mostly a C++ and Delphi guy and still dabble in C++ from time to time. I do web apps quite a bit so I am reasonably proficient with Javascript, JQuery and CSS. I have also done a few Java applications. I started web programming with CGI and live mostly in the ASP.NET MVC world these days. I am trying to decide on which platform/OS and tool to select. I am concerned with the size of the market available for my applications as well as the marketibility of the skills I will pick up. The apps I have in mind would work on both phones and pads. Some aspects of what I have in mind will play better on the bigger screens that will be available on pads. Here are the options I am considering: Apple iPhone/iPad using pure Apple SDK (Objective-C) Apple iPhone/iPad using Mono Touch (C#) Android using pure Android SDK (Java) Multiple platforms using something like Titanium to generate native apps from web technologies (HTML, CSS and Javascript) Multiple platforms using HTML5 web applications that run in the browser (HTML, CSS and Javascript). Which option would you choose? Do you have a different suggestion? What are the pros and cons?

    Read the article

  • JPA 2 Criteria API: why is isNull being ignored when in conjunction with equal?

    - by Vítor Souza
    I have the following entity class (ID inherited from PersistentObjectSupport class): @Entity public class AmbulanceDeactivation extends PersistentObjectSupport implements Serializable { private static final long serialVersionUID = 1L; @Temporal(TemporalType.DATE) @NotNull private Date beginDate; @Temporal(TemporalType.DATE) private Date endDate; @Size(max = 250) private String reason; @ManyToOne @NotNull private Ambulance ambulance; /* Get/set methods, etc. */ } If I do the following query using the Criteria API: CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<AmbulanceDeactivation> cq = cb.createQuery(AmbulanceDeactivation.class); Root<AmbulanceDeactivation> root = cq.from(AmbulanceDeactivation.class); EntityType<AmbulanceDeactivation> model = root.getModel(); cq.where(cb.isNull(root.get(model.getSingularAttribute("endDate", Date.class)))); return em.createQuery(cq).getResultList(); I get the following SQL printed in the log: FINE: SELECT ID, REASON, ENDDATE, UUID, BEGINDATE, VERSION, AMBULANCE_ID FROM AMBULANCEDEACTIVATION WHERE (ENDDATE IS NULL) However, if I change the where() line in the previous code to this one: cq.where(cb.isNull(root.get(model.getSingularAttribute("endDate", Date.class))), cb.equal(root.get(model.getSingularAttribute("ambulance", Ambulance.class)), ambulance)); I get the following SQL: FINE: SELECT ID, REASON, ENDDATE, UUID, BEGINDATE, VERSION, AMBULANCE_ID FROM AMBULANCEDEACTIVATION WHERE (AMBULANCE_ID = ?) That is, the isNull criterion is totally ignored. It is as if it wasn't even there (if I provide only the equal criterion to the where() method I get the same SQL printed). Why is that? Is it a bug or am I missing something?

    Read the article

  • How do I assert that two arbitrary type objects are equivalent, without requiring them to be equal?

    - by Tomas Lycken
    To accomplish this (but failing to do so) I'm reflecting over properties of an expected and actual object and making sure their values are equal. This works as expected as long as their properties are single objects, i.e. not lists, arrays, IEnumerable... If the property is a list of some sort, the test fails (on the Assert.AreEqual(...) inside the for loop). public void WithCorrectModel<TModelType>(TModelType expected, string error = "") where TModelType : class { var actual = _result.ViewData.Model as TModelType; Assert.IsNotNull(actual, error); Assert.IsInstanceOfType(actual, typeof(TModelType), error); foreach (var prop in typeof(TModelType).GetProperties()) { Assert.AreEqual(prop.GetValue(expected, null), prop.GetValue(actual, null), error); } } If dealing with a list property, I would get the expected results if I instead used CollectionAssert.AreEquivalent(...) but that requires me to cast to ICollection, which in turn requries me to know the type listed, which I don't (want to). It also requires me to know which properties are list types, which I don't know how to. So, how should I assert that two objects of an arbitrary type are equivalent? Note: I specifically don't want to require them to be equal, since one comes from my tested object and one is built in my test class to have something to compare with.

    Read the article

  • How to cast C struct just another struct type if their memory size are equal?

    - by Eonil
    I have 2 matrix structs means equal data but have different form like these: // Matrix type 1. typedef float Scalar; typedef struct { Scalar e[4]; } Vector; typedef struct { Vector e[4]; } Matrix; // Matrix type 2 (you may know this if you're iPhone developer) struct CATransform3D { CGFloat m11, m12, m13, m14; CGFloat m21, m22, m23, m24; CGFloat m31, m32, m33, m34; CGFloat m41, m42, m43, m44; }; typedef struct CATransform3D CATransform3D; Their memory size are equal. So I believe there is a way to convert these types without any pointer operations or copy like this: // Implemented from external lib. CATransform3D CATransform3DMakeScale (CGFloat sx, CGFloat sy, CGFloat sz); Matrix m = (Matrix)CATransform3DMakeScale ( 1, 2, 3 ); Is this possible? Currently compiler prints an "error: conversion to non-scalar type requested" message.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >