Search Results

Search found 37568 results on 1503 pages for 'iif function'.

Page 108/1503 | < Previous Page | 104 105 106 107 108 109 110 111 112 113 114 115  | Next Page >

  • Function template accepting nothing less than a bidirectional iterator or a pointer

    - by san
    I need a function template that accepts two iterators that could be pointers. If the two arguments are random_access iterators I want the return type to be an object of std::iterator<random_access_iterator_tag, ...> type else a std::iterator<bidirectional_iterator_tag, ...> type. I also want the code to refuse compilation if the arguments are neither a bidirectional iterator, nor a pointer. I cannot have dependency on third party libraries e.g. Boost Could you help me with the signature of this function so that it accepts bidirectional iterators as well as pointers, but not say input_iterator, output_iterator, forward_iterators. One partial solution I can think of is the following template<class T> T foo( T iter1, T iter2) { const T tmp1 = reverse_iterator<T>(iter1); const T tmp2 = reverse_iterator<T>(iter2); // do something } The idea is that if it is not bidirectional the compiler will not let me construct a reverse_iterator from it.

    Read the article

  • Is it possible get the functionality of namespaces inside a class?

    - by CowKingDeluxe
    I have the following code: Public Class Form1 Private Function Step1_Execute() As Boolean Return Step1_Verify() End Function Private Function Step1_Verify() As Boolean Return True End Function Private Function Step2_Execute() As Boolean Return Step2_Verify() End Function Private Function Step2_Verify() As Boolean Return True End Function End Class What I would like to do is be able to separate the code, similar to the following (which obviously doesn't work): Public Class Form1 Namespace Step1 Private Function Step1_Execute() As Boolean Return Step1_Verify() End Function Private Function Step1_Verify() As Boolean Return True End Function End Namespace Namespace Step2 Private Function Step2_Execute() As Boolean Return Step2_Verify() End Function Private Function Step2_Verify() As Boolean Return True End Function End Namespace End Class I would like the functionality of namespaces inside of a class, as in something that would let me call Step2.Execute() instead of having to put Step2_ in front of a whole bunch of functions. I don't want to have to create separate classes / modules for step1, step2, etc. Is there a way that I can accomplish namespace functionality from inside a class?

    Read the article

  • Runtime error in sml function

    - by Rpant
    I am writing this function in sml fun removeNodeswithNoIncoming((x:int,y)::xs,element:int) = if x=element then removeNodeswithNoIncoming (xs , element) else (x,y) :: removeNodeswithNoIncoming (xs , element) | removeNodeswithNoIncoming(nil,element) = nil; the function takes list of tuples [(0,0),(0,1)(1,2)] and another element 0 if first element of the tuples is same as second parameter , it removes it from the list The o/p for the above list should be [(1,2)] Unfortunately , the code is not working for the above input. Though there are other inputs for which it works - removeNodeswithNoIncomingEdge([(0,1),(0,2),(1,2)],0); stdIn:30.1-30.30 Error: unbound variable or constructor: removeNodeswithNoIncomi ngEdge - removeNodeswithNoIncomingEdge([(0,1),(0,2),(1,2),(1,4)],0); stdIn:1.2-1.31 Error: unbound variable or constructor: removeNodeswithNoIncoming Edge

    Read the article

  • call function after appending button

    - by Mahmoud
    i make jquery code add html elemnt button2 when event click on button1 , and make another to add another html elemnt to div when click on button 2 the first one run but the second not !! how solve this problem ? example of problem var button2='<input type="button" vale="add" id="idbutton2" >'; $('#idbutton1').click(function(){ $('#divid1').html(button2); }); $('#idbutton2').click(function(){ $('#divid2').html("text"); }); the button 2 add to div and i want run jquery when click on button 2

    Read the article

  • Creating anonymous functions in loop with not the same arguments

    - by onio9
    Hello! I want to make in loop set of buttons, and add to them some events, but anonymous functions is the same. I write example code: for(var i:int=0;i<5;i++) { var button:SimpleButton = new SimpleButton(...); ... button.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void { trace(i); }); } ... And I want to trace 1,2,3.. from click buttons instead of 4,4,4,4 .. Do you know how can I make this ?

    Read the article

  • Function chaining depending on boolean result

    - by Markive
    This is just an efficiency question really.. I'm interested to know if there is a more efficient or logical way that people use to handle this sort of scenario. In my asp.net application I am running a script to generate a new project my code at the top level looks like this: Dim ok As Boolean = True ok = createFolderStructure() If ok Then ok = createMDB() If ok Then ok = createProjectConfig() If ok Then ok = updateCompanyConfig() I create a boolean and each function returns a boolean result, the next function in this chain will only run if the previous one was successful. I do this because an asp.net application will continue to run through the page life cycle unless there is an unhandled exception and I don't want my whole application to be screwed up if something in the chain goes wrong (there is a lot of copying and deleting of files etc.. in this example). I was just wondering how other people handle this scenario? the vb.net single line if statement is quite succinct but I'm wondering if there is a better way?

    Read the article

  • Warning that users of the function must handle

    - by Hagai
    I am looking for a way to set warning that the user will have to respond. In a sense I would like to use late exception mechanize that occur after the function already finished executing.and returned the wanted value. SomeObject Foo(int input) { SomeObject result; // do something. oh, we need to warn the user. return result; } void Main() { SomeObject object; object = Foo(1); // after copy consturctor is done I would like an exception to be thrown } EDIT: The title to users of the function

    Read the article

  • Execute function by pressing "return" using jQuery?

    - by Axel
    Hi, i have two text inputs like the following, i don't want to use <form> , so i want when people press "return" after filling the inputs, a function called "doit()" should be executed. <script> function doit(){ alert("you submitted the info"); ..........ajax code........ } </script> <input type="text" id="email" /> <input type="text" id="skills" /> Thanks

    Read the article

  • Can the below function be improve?(C#3.0)

    - by Newbie
    I have the below function public static List<DateTime> GetOnlyFridays(DateTime endDate, int weeks, bool isIncludeBaseDate) { //Get only the fridays from the date range List<DateTime> dtlist = new List<DateTime>(); List<DateTime> tempDtlist = (from dtFridays in GetDates(endDate, weeks) where dtFridays.DayOfWeek == DayOfWeek.Friday select dtFridays).ToList(); if (isIncludeBaseDate) { dtlist = tempDtlist.Skip(1).ToList(); dtlist.Add(endDate); } else { dtlist = tempDtlist; } return dtlist; } What basically I am doing is getting the datelist using the GetDates function and then depending on the isIncludeBaseDate bool value(if true) skipping the last date and adding the Base Date It is working fine but can this program can be improve? I am using C#3.0 and Framework 3.5 Thanks

    Read the article

  • How to Create an Array from a Single Variable and Form Multiple Foreach Loops?

    - by matphoto
    I'm fairly proficient in HTML/CSS, but very new when it comes to the likes of PHP and Javascript. I've jumped headfirst into coding Wordpress shortcodes (basically php functions), and so far, through trial and error and seemingly endless browser refreshes, I've been able to figure everything out. I just hit a huge wall though, hence why I'm here. Basically, I'm trying to give an attribute a list of values like: attr="23, 95, 136, ect" The function then needs to take that attribute variable and create an array with it: $arr = array($attr); To me that seems as if it would work, but the array takes the whole list as one value instead. After doing that I want to create a foreach loop that parses each number from the list, possibly through yet another foreach loop if possible, and returns a section of code for each one, and I'm not quite sure how to pull that off either. Any feedback would be greatly appreciated.

    Read the article

  • How to map PageDown and PageUp Keys to function normally

    - by mtk
    When I open a document using vi or vim, I am unable to navigate the page using Page Up and Page Down keys. On pressing these keys, vim seems to behave in abnormal maaner, and changes the case of character beneath the cursor. It then takes few seconds to come back again in insert mode. Please let me know, how to map these keys, so that on pressing them I can scroll through pages smoothly just like Ctrl+ (f / b / u / d ).

    Read the article

  • Java Swing- Create a function to add elements to JScrollPanel

    - by battousai622
    I want to create a function so that i can call add JLabel's, etc inside the JScrollPanel. I am not sure what the command is in NetBeans. I tried doing JScrollPanel - events - container - componentAdded to create the code below. But nothing shows up when i add code to that function. private void initComponents() { scrollPanel = new javax.swing.JScrollPane(); scrollPanel.addContainerListener(new java.awt.event.ContainerAdapter() { public void componentAdded(java.awt.event.ContainerEvent evt) { scrollPanelComponentAdded(evt); } } private void scrollPanelComponentAdded(java.awt.event.ContainerEvent evt) { System.out.println("main"); } Any help would be great, thanks.

    Read the article

  • Notepad Tutorial: deleteDatabase() function

    - by FelixA
    Hello I have a short question to the notepad tutorial on the android website. I wrote a simple function in the tutorial code to delete the whole database. It looks like this: DataHelper.java public void deleteDatabase() { this.mDb.delete(DATABASE_NAME, null, null); } Notepadv1.java @Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); menu.add(0, DELETE_ID, 0, "Delete whole Database"); return result; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case DELETE_ID: mDbHelper.deleteDatabase(); return true; } return super.onOptionsItemSelected(item); } But when I run the app and try to delete the database I will get this error in LogCat: sqlite returned: error code = 1, msg= no such table: data Can you help how to fix this problem. It seems that the function deleteDatabase can not reach the database. Thank you very much. Felix

    Read the article

  • How to define a function which repeats itself when passed an argument

    - by ~unutbu
    Is there an easy way to define a function which repeats itself when passed an argument? For example, I've defined the following function (defun swap-sign () (interactive) (search-forward-regexp "[+-]") (if (equal (match-string 0) "-") (replace-match "+") (replace-match "-")) ) I'd like C-u swap-sign to call swap-sign four times. I've tried (defun swap-sign (&optional num) (interactive) (let ((counter 0) (num (if num (string-to-number num) 0))) (while (<= counter num) (search-forward-regexp "[+-]") (if (equal (match-string 0) "-") (replace-match "+") (replace-match "-")) (setq counter (1+ counter))))) but C-u swap-sign still only runs swap-sign (or perhaps more precisely, the body of the while-loop) once. I'm guessing it is because if num is not the right way to test if num is an empty string. Am I on the right track, or is there a better/easier way to extend swap-sign?

    Read the article

  • Overloaded function print

    - by Olga Shirokova
    For one of the assignments I need to create an overloaded function print that prints an element or all elements of an array. I have no problem with printing the entire array: for( int i = 0; i < size; i++) cout << list [ i ] <<endl; But how do I make the same function to print only one particular element? The way I see it is to ask a user what to print, either one element or all numbers. Or am I missing something here?

    Read the article

  • JQuery Div not animating in click function

    - by Doug
    Hi Everyone! I have the following code, I am attempting to have a div animate on a click event, but for some reason the div is immediately moving to the location and it's not animating to the coordinates specified, what am I doing wrong here? code: $(document).ready(function() { $('#example1').click(function(e){ var x = e.pageX - this.offsetLeft; var y = e.pageY - this.offsetTop; $('#example1-xy').html("X: " + x + " Y: " + y); var leftOfShip = x; //var leftOfShip = document.getElementById("ship").style.left + 20; $("#ship").animate({left: $("#ship").css("left",leftOfShip)},5000); }); }); Any Advice would be of help!!

    Read the article

  • Python: Using `copyreg` to define reducers for types that already have reducers

    - by cool-RR
    (Keep in mind I'm working in Python 3, so a solution needs to work in Python 3.) I would like to use the copyreg module to teach Python how to pickle functions. When I tried to do it, the _Pickler object would still try to pickle functions using the save_global function. (Which doesn't work for unbound methods, and that's the motivation for doing this.) It seems like _Pickler first tries to look in its own dispatch for the type of the object that you want to pickle before looking in copyreg.dispatch_table. I'm not sure if this is intentional. Is there any way for me to tell Python to pickle functions with the reducer that I provide?

    Read the article

  • How to create a bash function with variable parameters/arguments to grep several keywords/tags

    - by CornSmith
    I'm using the :!grep "tag1" filename | grep "tag2" filename | grep -n "tag3 or more" filename command in vim to search for my code snippets based on their tags (a simple comment at the top of a snippet) in one big file. I use snippets to remember tricky things. This is painful to write out each time. I'd like to make an alias, or function to do something like this: :!greptag tag1 tag2 ... tag39 And it should search the current doc and return the lines with all the tags on them. Vim is set to interactive shell mode so that it can parse my bashrc for aliases/functions. set shellcmdflag=-ic How can I construct a function that allows for variable arguments like this in bash?

    Read the article

  • Change function into dependencyproperty

    - by Jaya Willianto
    Hi everyone.. I am new to XAML and WPF and I am learning about DependencyProperty and Path. For example, I have a function like this public byte[] DownloadPicture() { WebClient webClient = new WebClient(); byte[] data; data = webClient.DownloadData("https://graph.facebook.com/4/picture&type=large"); return data; } and I have dependencyproperty like this public static DependencyProperty DownloadPicProperty = DependencyProperty.Register("DownloadPic", typeof(byte), typeof(ImageControl), new PropertyMetadata(false)); How can I connect the DependencyProperty with the DownloadPicture function I wrote? Any suggestions? What should I write in the CLR wrapper?

    Read the article

  • jQuery show/hide for FAQ using the next() function

    - by jon_brockman
    Maybe it's because it's Friday but I'm stuck on a simple problem. I'm building a FAQ page where a user clicks on a question, revealing the answer beneath it. I'm trying to get the next() function to just grab the next instance of an "answer" div but, despite not getting any JS errors, the hidden div isn't showing. Here's the code: .answer { display:none; } $("a.question").click(function(){ $(this).next(".answer").toggle(); }); <a href="#" class="question">Queston 1</a> <div class="answer">Answer 1</div> <a href="#" class="question">Queston 2</a> <div class="answer">Answer 2</div>

    Read the article

  • How to make my view better to save Django

    - by user558251
    Hy guys sorry for this post but i need help with my application, i need optimize my view. I have 5 models, how i can do this? def save(request): # get the request.POST in content if request.POST: content = request.POST dicionario = {} # create a dict to get the values in content for key,value in content.items(): # get my fk Course.objects if key == 'curso' : busca_curso = Curso.objects.get(id=value) dicionario.update({key:busca_curso}) else: dicionario.update({key:value}) #create the new teacher Professor.objects.create(**dicionario) my questions are? 1 - How i can do this function in a generic way? Can I pass a variable in a %s to create and get? like this way ? foo = "Teacher" , bar = "Course" def save(request, bar, foo): if request post: ... if key == 'course' : get_course = (%s.objects.get=id=value) %bar ... (%s.objects.create(**dict)) %foo ??? i tried do this in my view but don't work =/, can somebody help me to make this work ? Thanks

    Read the article

  • document.forms.gallery_form.submit is not a function

    - by Keene Maverick
    I swear, I have this exact thing working on another page. I'm such a javascript noob it's embarrassing... function delete_gallery() { var gallery = document.getElementById('gallery_id').value; var form = document.getElementById('gallery_form'); form.setAttribute('action', 'index.php?action=delete&section=galleries&id='+gallery); document.forms['gallery_form'].submit(); } Inspecting the element shows that it's updating the action correctly : <form method="post" action="index.php?action=delete&amp;section=galleries&amp;id=12" name="gallery_form" id="gallery_form"><input type="hidden" value="12" id="gallery_id" name="gallery_id"><p>Name: <input type="text" name="name" value="Woo"></p><p>Description:<br><textarea name="description">Dee</textarea><input type="hidden" value="2" name="artist"></p><p><input type="submit" value="Submit" name="submit"> </p></form> Here's the button I use to call the function, it's in a table below the form: <button onclick="delete_gallery()" type="button">Delete Gallery</button>

    Read the article

  • How to use YT thumb in plugin

    - by Frank Morrison
    I'm using two plugins on my wordpress site: Auto post youtube Pulls a youtube video then drafts it for me. I use this on my index page beside the post code and the thumbnail appears great: <?php tern_wp_youtube_image(); ?> Top Ten Which I use to display the most viewed posts on a page. Not looking great at the moment, but will fix styling later. This is the code to display popular posts: <?php if(function_exists('tptn_show_pop_posts')) tptn_show_pop_posts(); ?> Is it possible for me to use the youtube image in the popular post function? Or is it because they are seperate they cannot work together without a lot of code? Thanks in advance! Some links incase anybody wants to check them out http://wordpress.org/extend/plugins/top-10/ http://www.ternstyle.us/products/plugins/wordpress/wordpress-automatic-youtube-video-posts/wordpress-automatic-youtube-video-posts-functions

    Read the article

  • jQuery - Animate function

    - by Arun Kumar
    I have a piece of code shown below: $(".tagArea li").mouseover(function(){ $(this).animate({ borderWidth: "2px" }, 1000 ); }); $(".tagArea li").mouseout(function () { $(this).animate({ borderWidth: "1px" }, 1000 ); }); When I try to hover it on a particular list item, it properly animates but doesn't stop doing just once. It keeps doing 2 or 3 times. How to avoid this, I 've tried many a times but no positive result occurs to me. Kindly help.

    Read the article

< Previous Page | 104 105 106 107 108 109 110 111 112 113 114 115  | Next Page >