Search Results

Search found 2995 results on 120 pages for 'logical operators'.

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

  • C++ infix to postfix conversion for logical conditions

    - by Gopalakrishnan Subramani
    I want to evaluate one expression in C++. To evaluate it, I want the expression to be converted to prefix format. Here is an example wstring expression = "Feature1 And Feature2"; Here are possible ways. expression = "Feature1 And (Feature2 Or Feature3)"; expression = "Not Feature1 Or Feature3"; Here And, Or, Not are reserved words and parentheses ("(", )) are used for scope Not has higher precedence And is set next precedence to Not Or is set to next precedence to And WHITE SPACE used for delimiter. Expression has no other elements like TAB, NEWLINE I don't need arithmetic expressions. I can do the evaluation but can somebody help me to convert the strings to prefix notation?

    Read the article

  • The use of mod operators in ada

    - by maddy
    Hi all, Can anyone please tell me the usage of the following declarations shown below.I am a beginner in ada language.I had tried the internet but that was not clear enough. type Unsigned_4 is mod 2 ** 4; for Unsigned_4'Size use 4;

    Read the article

  • Logical python question - handeling directories and files in them

    - by Konstantin
    Hello! I'm using this function to extract files from .zip archive and store it on the server: def unzip_file_into_dir(file, dir): import sys, zipfile, os, os.path os.makedirs(dir, 0777) zfobj = zipfile.ZipFile(file) for name in zfobj.namelist(): if name.endswith('/'): os.mkdir(os.path.join(dir, name)) else: outfile = open(os.path.join(dir, name), 'wb') outfile.write(zfobj.read(name)) outfile.close() And the usage: unzip_file_into_dir('/var/zips/somearchive.zip', '/var/www/extracted_zip') somearchive.zip have this structure: somearchive.zip 1.jpeg 2.jpeg another.jpeg or, somethimes, this one: somearchive.zip somedir/ 1.jpeg 2.jpeg another.jpeg Question is: how do I modify my function, so that my extracted_zip catalog would always contain just images, not images in another subdirectory, even if images are stored in somedir inside an archive.

    Read the article

  • How to implement == or >= operators for generic type

    - by momsd
    I have a generic type Foo which has a internal generic class Boo. Boo class a property Value of type K. In a method inside Foo i want to do a boo.Value >= value Note that second operand value is of type T. while compiling i am getting following error: Operator '=' cannot be applied to operands of type 'T' and 'T' Can anyone please tell me whats the problem here?

    Read the article

  • Sikuli List of Functions & Operators

    - by PPTim
    Hello, I've just discovered Sikuli, and would like to see a comprehensive functions list without digging through the online-examples and demos. Has anyone found such a list? Furthermore, apparently Sikuli supports more complex loops and function calls as well, and seems to be based in Python(!!). Examples would be great. Thanks.

    Read the article

  • If-statement with logical OR

    - by exiter2000
    public class Test{ public static void main(String args[]){ int a = 0; int b = 1; int c = 10; if ( a == 0 || b++ == c ){ a = b + c; }else{ b = a + c; } System.out.println("a: " + a + ",b: " + b + ",c: " + c); } } Ok, this is Java code and the output is a: 11,b: 1,c: 10 And I believe the C acts same as Java in this case That is because second condition(b++ == c) would never executed if the first condition is true in 'OR' operator. There is a "NAME" for this. I just don't remember what it is. Does anyone know what this is called?? Thanks in advance

    Read the article

  • What's the logical value of "string" in python?

    - by Kamran
    I erroneously wrote this code in python: name = input("what is your name?") if name == "Kamran" or "Samaneh": print("That is a nice name") else: print("You have a boring name ;)") It always prints out "That is a nice name" even when the input is neither "Kamran" nor "Samaneh". Am I correct in saying that it considers "Samaneh" as a true? why? By the way, I already noticed my mistake. The correct form is: if name == "Kamran" or name == "Samaneh":

    Read the article

  • some logical error in taking up character in java

    - by Himanshu Aggarwal
    This is my code... class info{ public static void main (String[]args) throws IOException{ char gen; while(true) { //problem occurs with this while System.out.print("\nENTER YOUR GENDER (M/F) : "); gen=(char)System.in.read(); if(gen=='M' || gen=='F' || gen=='m' || gen=='f'){ break; } } System.out.println("\nGENDER = "+gen); } } This is my output... ENTER YOUR GENDER (M/F) : h ENTER YOUR GENDER (M/F) : ENTER YOUR GENDER (M/F) : ENTER YOUR GENDER (M/F) : m GENDER = m Could someone please help me understand why it is asking for the gender so many times.

    Read the article

  • C: switch case with logical operator

    - by Er Avinash Singh
    While I am new to c and want help in this program my code is : #include<stdio.h> #include<conio.h> void main(){ int suite=2; switch(suite) { case 1||2: printf("hi"); case 3: printf("byee"); default: printf("hello"); } printf("I thought somebody"); getche(); } I am working in turbo c and it shows no error and the output is helloI thought somebody Please, let me know how is this working ??? note :- here break is not the case as I intentionally left them.

    Read the article

  • C++ Implicit Conversion Operators

    - by Imbue
    I'm trying to find a nice inheritance solution in C++. I have a Rectangle class and a Square class. The Square class can't publicly inherit from Rectangle, because it cannot completely fulfill the rectangle's requirements. For example, a Rectangle can have it's width and height each set separately, and this of course is impossible with a Square. So, my dilemma. Square obviously will share a lot of code with Rectangle; they are quite similar. For examlpe, if I have a function like: bool IsPointInRectangle(const Rectangle& rect); it should work for a square too. In fact, I have a ton of such functions. So in making my Square class, I figured I would use private inheritance with a publicly accessible Rectangle conversion operator. So my square class looks like: class Square : private Rectangle { public: operator const Rectangle&() const; }; However, when I try to pass a Square to the IsPointInRectangle function, my compiler just complains that "Rectangle is an inaccessible base" in that context. I expect it to notice the Rectangle operator and use that instead. Is what I'm trying to do even possible? If this can't work I'm probably going to refactor part of Rectangle into MutableRectangle class. Thanks.

    Read the article

  • Lazy evaluation with ostream C++ operators

    - by SavinG
    I am looking for a portable way to implement lazy evaluation in C++ for logging class. Let's say that I have a simple logging function like void syslog(int priority, const char *format, ...); then in syslog() function we can do: if (priority < current_priority) return; so we never actually call the formatting function (sprintf). On the other hand, if we use logging stream like log << LOG_NOTICE << "test " << 123; all the formating is always executed, which may take a lot of time. Is there any possibility to actually use all the goodies of ostream (like custom << operator for classes, type safety, elegant syntax...) in a way that the formating is executed AFTER the logging level is checked ?

    Read the article

  • Lambda Functions in PHP aren't Logical

    - by Chacha102
    Note: I have condensed this article into my person wiki: http://wiki.chacha102.com/Lambda - Enjoy I am having some troubles with Lambda style functions in PHP. First, This Works: $foo = function(){ echo "bar"; }; $foo(); Second, This Works: class Bar{ public function foo(){ echo "Bar"; } Third, This works: $foo = new stdClass; $foo->bar = function(){ echo "bar"; }; $test = $foo->bar; $test(); But, this does not work: $foo = new stdClass; $foo->bar = function(){ echo "bar"; }; $foo->bar(); And, this does not work class Bar{ public function foo(){ echo "Bar"; } $foo = new Bar; $foo->foo = function(){ echo "foo"; }; $foo->foo(); // echo's bar instead of Foo. My Question is Why?, and how can I assure that both this: $foo->bar = function(){ echo "test"; }; $foo->bar(); and this $foo = new Bar; $foo->bar(); are called properly? Extra Points if you can point to documentation stating why this problem occurs.

    Read the article

  • has_many relation doesn't seems right or logical, some thing like belongs_to_many looks right

    - by Vijendra
    My situation is like this. Company has many users and users may belongs to many companies. And current implementation is something like below. class Company has_many :employments has_many :users, :through = :employments end class Employment belongs_to :company belongs_to :user end class User has_many :employments has_many :companies, :through = :employments #This doesn't looks correct end User has many companies doesn't looks logically meaningful.It must be some thing like belongs_to_many companies. Do I need to use has_and_belongs_to_many? But that also will gives the same meaning. Can some one please suggest the right way for representing these relationships?

    Read the article

  • Can I create ternary operators in C# ?

    - by Scott S
    I want to create a ternary operator for a < b < c which is a < b && b < c. or any other option you can think of that a < b c and so on... I am a fan of my own shortform and I have wanted to create that since I learned programming in high school. How?

    Read the article

  • In Python, are there builtin functions for elementwise map of boolean operators over tuples of lists

    - by bshanks
    For example, if you have n lists of bools of the same length, then elementwise boolean AND should return another list of that length that has True in those positions where all the input lists have True, and False everywhere else. It's pretty easy to write, i just would prefer to use a builtin if one exists (for the sake of standardization/readability). Here's an implementation of elementwise AND: def eAnd(*args): return [all(tuple) for tuple in zip(*args)] example usage: >>> eAnd([True, False, True, False, True], [True, True, False, False, True], [True, True, False, False, True]) [True, False, False, False, True] thx

    Read the article

  • has_many relation doesn't seems right or logical in business perceptive, needed some thing like belo

    - by Vijendra
    My situation is like this. Company has many users and users may belongs to many companies. And current implementation is something like below. class Company has_many :employments has_many :users, :through = :employments end class Employment belongs_to :company belongs_to :user end class User has_many :employments has_many :companies, :through = :employments #This doesn't looks correct end It works, but "user has many companies" doesn't looks logically meaningful. It must be some thing like belongs_to_many companies. Do I need to use has_and_belongs_to_many? Can some one please suggest the right way for representing these relationships?

    Read the article

  • Hex to bin after logical operations

    - by user355926
    I want: 111 || 100 ---> 111, not 1 100 && 100 ---> 100, not 1 101 && 010 ---> 000, not 0 Broken code #include <stdio.h> main(void){ string hexa = 0xff; strig hexa2 = 0xf1; // CONVERT TO INT??? cast int hexa3 = hexa || hexa2; int hexa4 = hexa && hexa2; puts(hexa3); puts(hexa4); }

    Read the article

  • Logical Programming Problem

    - by user353060
    Hello, I've been trying to solve this problem for quite sometime but I am having trouble with it. Let's say on a trigger, you receive values. First trigger: You get 1 Second trigger: You get 1, 2 Third trigger: You get 1, 2, 3 So, I store 1. For 2nd trigger, I store 2 since 1 already exist. For 3rd trigger, I store 3 since 1,2 already exist so in total I have stored 1,2,3 As you can see, we can easily check for new values, if old != new. Here's come the problem: Fourth trigger: You get 1, 2, 4 For 4th trigger, I store 1, 2 because it exists but how do I check against 3 and remove 3 from store and check if 4 is new? If you are having problems understanding this, feel free to clarify. Thanks!

    Read the article

  • C++ STL question related to insert iterators and overloaded operators

    - by rshepherd
    #include <list> #include <set> #include <iterator> #include <algorithm> using namespace std; class MyContainer { public: string value; MyContainer& operator=(const string& s) { this->value = s; return *this; } }; int main() { list<string> strings; strings.push_back("0"); strings.push_back("1"); strings.push_back("2"); set<MyContainer> containers; copy(strings.begin(), strings.end(), inserter(containers, containers.end())); } The preceeding code does not compile. In standard C++ fashion the error output is verbose and difficult to understand. The key part seems to be this... /usr/include/c++/4.4/bits/stl_algobase.h:313: error: no match for ‘operator=’ in ‘__result.std::insert_iterator::operator* [with _Container = std::set, std::allocator ]() = __first.std::_List_iterator::operator* [with _Tp = std::basic_string, std::allocator ]()’ ...which I interpet to mean that the assignment operator needed is not defined. I took a look at the source code for insert_iterator and noted that it has overloaded the assignment operator. The copy algorithm must uses the insert iterators overloaded assignment operator to do its work(?). I guess that because my input iterator is on a container of strings and my output iterator is on a container of MyContainers that the overloaded insert_iterator assignment operator can no longer work. This is my best guess, but I am probably wrong. So, why exactly does this not work and how can I accomplish what I am trying to do?

    Read the article

  • Ternary Operators in JavaScript Without an "Else"

    - by Oscar Godson
    I've been using them forever, and I love them. To me they see cleaner and i can scan faster, but ever since I've been using them i've always had to put null in the else conditions that don't have anything. Is there anyway around it? E.g. condition ? x=true : null ; basically, is there a way to do: condition ? x=true; Now it shows up as a syntax error...

    Read the article

  • A logical problem with two tables

    - by Luke
    Hey guys, I created a list for fixtures. $result = mysql_query("SELECT date FROM ".TBL_FIXTURES." WHERE compname = '$comp_name' GROUP BY date"); $i = 1; $d = "Start"; while ($row = mysql_fetch_assoc($result)) { $odate = $row['date']; $date=date("F j Y", $row['date']); echo "<p>Fixture $i - $d to $date</p>"; } As you can see from the query, the date is displayed from the fixtures table. The way my system works is that when a fixture is "played", it is removed from this table. Therefore when the entire round of fixtures are complete, there wont be any dates for that round in this table. They will be in another table. Is there anyway I can run an other query for dates at the same time, and display only dates from the fixtures table if there isnt a date in the results table? "SELECT * FROM ".TBL_CONF_RESULTS." WHERE compid = '$_GET[id]' && type2 = '2' ORDER BY date" That would be the second query!

    Read the article

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