Search Results

Search found 5123 results on 205 pages for 'functional dependencies'.

Page 43/205 | < Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >

  • Cartesian Plane

    - by NuNu
    I'm trying to define a function in Haskell that takes an integer argument c and returns the list of all points on the cartesian plane of the form (x/c,y/c) where x and y are integers. x/c is between -2 and 1 and y/r is between -1 and 1 This is what I've gotten so far which I'm almost sure is right but I'm getting a parse error on input = when I run it particularly at this line: cart xs ys c = [(y/c,x/c) | x <- xs, y <- ys] plane :: Int -> [a] plane c = cart [-1*c .. 1*c] [-2*c .. 1*c] c cart xs ys c = [(y/c,x/c) | x <- xs, y <- ys] A sample output would be: plane 1 would generate: [(-2.0, -1.0), (-1.0, -1.0), ( 0.0, -1.0), ( 1.0, -1.0), (-2.0, 0.0), (-1.0, 0.0), ( 0.0, 0.0), ( 1.0, 0.0), (-2.0, 1.0), (-1.0, 1.0), ( 0.0, 1.0), ( 1.0, 1.0)] Anyone have any idea how I can fix this! Thanks

    Read the article

  • Abort early in a fold

    - by Heptic
    What's the best way to terminate a fold early? As a simplified example, imagine I want to sum up the numbers in an Iterable, but if I encounter something I'm not expecting (say an odd number) I might want to terminate. This is a first approximation def sumEvenNumbers(nums: Iterable[Int]): Option[Int] = { nums.foldLeft (Some(0): Option[Int]) { case (None, _) => None case (Some(s), n) if n % 2 == 0 => Some(s + n) case (Some(_), _) => None } } However, this solution is pretty ugly (as in, if I did a .foreach and a return -- it'd be much cleaner and clearer) and worst of all, it traverses the entire iterable even if it encounters a non-even number. So what would be the best way to write a fold like this, that terminates early? Should I just go and write this recursively, or is there a more accepted way?

    Read the article

  • How do I code a tree of objects in Haskell with pointers to parent and children?

    - by axilmar
    I've got the following problem: I have a tree of objects of different classes where an action in the child class invalidates the parent. In imperative languages, it is trivial to do. For example, in Java: public class A { private List<B> m_children = new LinkedList<B>(); private boolean m_valid = true; public void invalidate() { m_valid = false; } public void addChild(B child) { m_children.add(child); child.m_parent = this; } } public class B { public A m_parent = null; private int m_data = 0; public void setData(int data) { m_data = 0; m_parent.invalidate(); } } public class Main { public static void main(String[] args) { A a = new A(); B b = new B(); b.setData(0); //invalidates A } } How do I do the above in Haskell? I cannot wrap my mind around this, since once I construct an object in Haskell, it cannot be changed. I would be much obliged if the relevant Haskell code is posted.

    Read the article

  • How can I bind the second argument in a function but not the first (in an elegant way)?

    - by Frank Osterfeld
    Is there a way in Haskell to bind the second argument but not the first of a function without using lambda functions or defining another "local" function? Example. I have a binary function like: sub :: Int -> Int -> Int sub x y = x - y Now if I want to bind the first argument, I can do so easily using (sub someExpression): mapSubFrom5 x = map (sub 5) x *Main> mapSubFrom5 [1,2,3,4,5] [4,3,2,1,0] That works fine if I want to bind the first n arguments without "gap". If I want to bind the second argument but not the first, the two options I am aware of are more verbose: Either via another, local, function: mapSub5 x = map sub5 x where sub5 x = sub x 5 *Main> mapSub5 [1,2,3,4,5] [-4,-3,-2,-1,0] Or using lambda: mapSub5 x = map (\x -> sub x 5) x While both are working fine, I like the elegance of "sub 5" and wonder if there is a similarly elegant way to bind the n-th (n 1) argument of a function?

    Read the article

  • JS best practice for member functions

    - by MickMalone1983
    I'm writing a little mobile games library, and I'm not sure the best practice for declaring member functions of instantiated function objects. For instance, I might create a simple object with one property, and a method to print it: function Foo(id){ this.id = id; this.print = function(){ console.log(this.id); }; }; However, a function which does not need access to 'private' members of the function does not need to be declared in the function at all. I could equally have written: function print(){ console.log(this.id); }; function Foo(id){ this.id = id; this.print = print; }; When the function is invoked through an instance of Foo, the instance becomes the context for this, so the output is the same in either case. I'm not entirely sure how memory is allocated with JS, and I can't find anything that I can understand about something this specific, but it seems to me that with the first example all members of Foo, including the print function, are duplicated each time it is instantiated - but with the second, it just gets a pointer to one, pre-declared function, which would save any more memory having to be allocated as more instances of Foo are created. Am I correct, and if I am, is there any memory/performance benefit to doing this?

    Read the article

  • How to resolve broken dependencies of gnome-shell-extensions-user-theme package?

    - by swift
    After unsuccessful upgrade of Gnome3 packages in new Precise Pangolin 64-bit environment I get this error: The following packages have unmet dependencies: gnome-shell-extensions : Conflicts: gnome-shell-extensions-user-theme but 3.2.0-2~webupd8~oneiric is to be installed I tried to remove by running sudo apt-get purge gnome-shell-extensions-user-theme but get this: Package gnome-shell-extensions-user-theme is not installed, so not removed My Gnome Classic profile works well but Gnome3 session can't run. How to resolve this error?

    Read the article

  • Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. Access is denied.

    - by datagridgirl
    I wanted to post a solution to an issue that comes up every time I have to setup a new developer in our organization:      Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. Access is denied.  My solution is to grant Full Control to the "Everyone" group to the folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files  I know there are other solutions to this problem, but this one seems the simplest for me.  Marcie

    Read the article

  • Can Scala be considered a functional superset of Java?

    - by Giorgio
    Apart from the differences in syntax, can Scala be considered a superset of Java that adds the functional paradigm to the object-oriented paradigm? Or are there any major features in Java for which there is no direct Scala equivalent? With major features I mean program constructs that would force me to heavily rewrite / restructure my code, e.g., if I had to port a Java program to Scala. Or can I expect that, given a Java program, I can port it to Scala almost line-by-line?

    Read the article

  • What norms/standards should I follow when writing a functional spec?

    - by user970696
    I would like to know what documents (ISO?) should I follow when I write a functional specification. Or what should designers follow when creating the system design? I was told that there was a progress in last years but was not told what the progress was in (college professor). Thank you EDIT: I do not speak about document content etc. but about standards for capturing requirements, for business analysis.

    Read the article

  • How to get a handle/reference to the current controller object inside a rails functional test?

    - by Dave Paroulek
    I must be missing something very simple, but can't find the answer to this. I have a method named foo inside bar_controller. I simply want to call that method from inside a functional test. Here's my controller: class BarsController < ApplicationController def foo # does stuff end end Here's my functional test: class BarsControllerTest << ActionController::TestCase def "test foo" do # run foo foo # assert stuff end end When I run the test I get: NameError: undefined local variable or method `foo' for #<BarsControllerTest:0x102f2eab0> All the documentation on functional tests describe how to simulate a http get request to the bar_controller which then runs the method. But I'd just like to run the method without hitting it with an http get or post request. Is that possible? There must be a reference to the controller object inside the functional test, but I'm still learning ruby and rails so need some help.

    Read the article

  • Where do you take mocking - immediate dependencies, or do you grow the boundaries...?

    - by Peter Mounce
    So, I'm reasonably new to both unit testing and mocking in C# and .NET; I'm using xUnit.net and Rhino Mocks respectively. I'm a convert, and I'm focussing on writing behaviour specifications, I guess, instead of being purely TDD. Bah, semantics; I want an automated safety net to work above, essentially. A thought struck me though. I get programming against interfaces, and the benefits as far as breaking apart dependencies goes there. Sold. However, in my behaviour verification suite (aka unit tests ;-) ), I'm asserting behaviour one interface at a time. As in, one implementation of an interface at a time, with all of its dependencies mocked out and expectations set up. The approach seems to be that if we verify that a class behaves as it should against its collaborating dependencies, and in turn relies on each of those collaborating dependencies to have signed that same quality contract, we're golden. Seems reasonable enough. Back to the thought, though. Is there any value in semi-integration tests, where a test-fixture is asserting against a unit of concrete implementations that are wired together, and we're testing its internal behaviour against mocked dependencies? I just re-read that and I think I could probably have worded it better. Obviously, there's going to be a certain amount of "well, if it adds value for you, keep doing it", I suppose - but has anyone else thought about doing that, and reaped benefits from it outweighing the costs?

    Read the article

  • What are unused/undeclared dependencies in maven ? What to do with them ?

    - by b7kich
    Maven dependency:analyze complains about the dependencies in my project. How does it determine which are unused and which are undeclared ? What should I do about them ? Example: $ mvn dependency:analyze ... [WARNING] Used undeclared dependencies found: [WARNING] org.slf4j:slf4j-api:jar:1.5.0:provided [WARNING] commons-logging:commons-logging:jar:1.1.1:compile [WARNING] commons-dbutils:commons-dbutils:jar:1.1-osgi:provided [WARNING] org.codehaus.jackson:jackson-core-asl:jar:1.6.1:compile ... [WARNING] Unused declared dependencies found: [WARNING] commons-cli:commons-cli:jar:1.0:compile [WARNING] org.mortbay.jetty:servlet-api:jar:2.5-20081211:test [WARNING] org.apache.httpcomponents:httpclient:jar:4.0-alpha4:compile [WARNING] commons-collections:commons-collections:jar:3.2:provided [WARNING] javax.mail:mail:jar:1.4:provided Note: A lot of these dependencies are used in my runtime container and I declared them as provided to avoid having same library on the classpath twice with different versions.

    Read the article

  • Whats are basic things you should kept in mind while writing functional tests?

    - by piemesons
    Hello, what kind of functionality should be covered in functional test? How to prioritize what are the functionality that must be covered in functional test. I can understand it depends upon on the project, whats the functionality present the project. Lets take a example of stackoverflow. Suppose we are developing a basic working model of this. What kind of functional test must be covered in this. Just brief what the key points while writing functional tests. (taking any basic functionality from this site just to understand the reference) Still its platform independent question.I am using ruby on rails developer, but keeping ruby on rails as mind will be preferable.

    Read the article

  • A tool to determine jar dependencies based on existing code?

    - by geoffeg
    Is there a tool that can determine .jar dependencies given a directory of .jar files and a separate directory of java source code? I need to generate Eclipse .classpath files based on an existing code base that doesn't have any dependencies defined. To be more specific, I've been given a large codebase consisting of a dozen or so J2EE-style projects and a single directory of jar files. My client uses a custom development and build framework that is just too arcane for me to use and get any real work done. The projects do not have any information about their dependencies, either between projects or to jar libraries. I would expect this tool would have to spin through each jar file, indexing the classes available in that file and then go through each file in the project source code tree and match up the dependencies, possibly writing out a .classpath file with the required jar files. I realize this is a rather simplistic view of the operation, as duplicate classes among the jar files and such might make things more difficult.

    Read the article

  • Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. Access is denied.

    I wanted to post a solution to an issue that comes up every time I have to setup a new developer in our organization:      Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. Access is denied.  My solution is to grant Full Control to the "Everyone" group to the folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files  I know there are other solutions to this problem, but this one seems the simplest for me.  M...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)

    - by B Jo
    I would like to upgrade to Ubuntu 13.04 since almost a month now. Am a pretty novice in linux and in software in general. My /boot is full : bijo@bijo-AMILO-Xi-2428:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/ubuntu-root 228G 7.7G 208G 4% / udev 1001M 4.0K 1001M 1% /dev tmpfs 404M 836K 403M 1% /run none 5.0M 0 5.0M 0% /run/lock none 1008M 156K 1008M 1% /run/shm none 100M 48K 100M 1% /run/user /dev/sda1 228M 222M 0 100% /boot I tried the : sudo apt-get purge $( dpkg --list | grep -P -o "linux-image-\d\S+" | grep -v $(uname -r | grep -P -o ".+\d") ) but i got this as reply E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution). infact I'm going round and round ... Can someone guide me through please? Thanks in advance for ur time

    Read the article

  • How to run 'apt-get install' to install all dependencies?

    - by michael
    I am running this in ubuntu server installation: sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 but I am getting this: Reading package lists... Building dependency tree... Reading state information... curl is already the newest version. gnupg is already the newest version. Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: build-essential : Depends: gcc (>= 4:4.4.3) but it is not going to be installed Depends: g++ (>= 4:4.4.3) but it is not going to be installed g++-multilib : Depends: cpp (>= 4:4.7.2-1ubuntu2) but it is not going to be installed Depends: gcc-multilib (>= 4:4.7.2-1ubuntu2) but it is not going to be installed Depends: g++ (>= 4:4.7.2-1ubuntu2) but it is not going to be installed Depends: g++-4.7-multilib (>= 4.7.2-1~) but it is not going to be installed How can I fix this?

    Read the article

  • Is there any functional difference between immutable value types and immutable reference types?

    - by Kendall Frey
    Value types are types which do not have an identity. When one variable is modified, other instances are not. Using Javascript syntax as an example, here is how a value type works. var foo = { a: 42 }; var bar = foo; bar.a = 0; // foo.a is still 42 Reference types are types which do have an identity. When one variable is modified, other instances are as well. Here is how a reference type works. var foo = { a: 42 }; var bar = foo; bar.a = 0; // foo.a is now 0 Note how the example uses mutatable objects to show the difference. If the objects were immutable, you couldn't do that, so that kind of testing for value/reference types doesn't work. Is there any functional difference between immutable value types and immutable reference types? Is there any algorithm that can tell the difference between a reference type and a value type if they are immutable? Reflection is cheating. I'm wondering this mostly out of curiosity.

    Read the article

  • How do I add unmet dependencies for unity-lens-music autogen.sh?

    - by nickform
    I would like to build unity-lens-music on my newly-upgraded Ubuntu 12.10 machine. I followed these instructions from the unity website to get the code. The README was empty but I guessed that ./autogen.sh would be a sensible place to start. Unfortunately it exits with the following error: checking for LENS_DAEMON... no configure: error: Package requirements (glib-2.0 >= 2.27 gobject-2.0 >= 2.27 gio-2.0 >= 2.27 gio-unix-2.0 >= 2.27 dee-1.0 >= 1.0.7 sqlite3 >= 3.7.7 gee-1.0 json-glib-1.0 unity >= 6.90.0 unity-extras >= 6.90.0 tdb >= 1.2.6) were not met: No package 'dee-1.0' found No package 'sqlite3' found No package 'gee-1.0' found No package 'json-glib-1.0' found No package 'unity' found No package 'unity-extras' found No package 'tdb' found When I attempt to satisfy the dependencies that aren't found using apt-get install I either find that there is no exact match (e.g. 'dee-1.0' which matches several packages), I already have the latest version (e.g. sqlite3, unity) or there is no match at all (e.g. unity-extras and tdb). There is a later suggestion to modify PKG_CONFIG_PATH if I have installed software in a non-standard location but, to my knowledge, I have not. How should I proceed?

    Read the article

  • Is an app that does nothing but link to a web site functional enough to meet Apple's iOS guidelines?

    - by Pointy
    I don't hang out on Programmers enough to know whether this question is "ok", so my apologies if not. I tried to make the title obvious so at least it can be closed quickly :-) The question is simple. My employer wants "home screen presence" (or at least the possibility thereof) on iOS devices (also Android but I'm mostly interested in Apple at the moment). Our actual application will be a pure web-delivered mobile-friendly application, so what we want on the homescreen is basically something that just acts as a link to bring up Safari (or Chrome now I guess; not important). I'm presuming that that's more-or-less possible; if not then that would be interesting too. I know that the Apple guidelines are such that low-functionality apps are generally rejected out of hand. There are a lot of existing apps that seem (to me) less functional than a link to something useful, but I'm not Apple of course. Because this seems like a not-too-weird situation, I'm hoping that somebody knows it's either definitely OK (maybe because there are many such apps) or definitely not OK. Note that I know about things like PhoneGap and I don't want that, at least not at the moment.

    Read the article

  • Languages with a clear distinction between subroutines that are purely functional, mutating, state-changing, etc?

    - by CPX
    Lately I've become more and more frustrated that in most modern programming languages I've worked with (C/C++, C#, F#, Ruby, Python, JS and more) there is very little, if any, language support for determining what a subroutine will actually do. Consider the following simple pseudo-code: var x = DoSomethingWith(y); How do I determine what the call to DoSomethingWith(y) will actually do? Will it mutate y, or will it return a copy of y? Does it depend on global or local state, or is it only dependent on y? Will it change the global or local state? How does closure affect the outcome of the call? In all languages I've encountered, almost none of these questions can be answered by merely looking at the signature of the subroutine, and there is almost never any compile-time or run-time support either. Usually, the only way is to put your trust in the author of the API, and hope that the documentation and/or naming conventions reveal what the subroutine will actually do. My question is this: Does there exist any languages today that make symbolic distinctions between these types of scenarios, and places compile-time constraints on what code you can actually write? (There is of course some support for this in most modern languages, such as different levels of scope and closure, the separation between static and instance code, lambda functions, et cetera. But too often these seem to come into conflict with each other. For instance, a lambda function will usually either be purely functional, and simply return a value based on input parameters, or mutate the input parameters in some way. But it is usually possible to access static variables from a lambda function, which in turn can give you access to instance variables, and then it all breaks apart.)

    Read the article

< Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >