Search Results

Search found 1117 results on 45 pages for 'conditional'.

Page 8/45 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Conditional installation with Wix

    - by Luca
    Is it possible to have a conditional installation configuration, slaved wth the Visual Studio configuration environment? For example, selecting DEBUG or RELEASE configuration, Wix selects different executables in the built installation.

    Read the article

  • xslt param conditional check

    - by LB
    I have a: <xsl:param name="SomeFlag" /> In my XSLT template, I want to do a conditional check on SomeFlag. Currently I'm doing it as: <xsl:if test="$SomeFlag = true"> SomeFlag is true! </xsl:if> Is this how we evaluate the the flag? I'm setting the param in C# as: xslarg.AddParam("SomeFlag", String.Empty, true); Any ideas?

    Read the article

  • conditional selects with jQuery and the Validation plugin

    - by dbonomo
    Hi, I've got a form that I am validating with the jQuery validation plugin. I would like to add a conditional select box (a selection box that is populated/shown depending on the selection of another) and have it validate as well. Here is what I have so far: $(document).ready(function(){ $("#customer_information").validate({ //disable the submit button after it is clicked to prevent multiple submissions submitHandler: function(form){ if(!this.wasSent){ this.wasSent = true; $(':submit', form).val('Please wait...') .attr('disabled', 'disabled') .addClass('disabled'); form.submit(); } else { return false; } }, //Customizes error placement errorPlacement: function(error, element) { error.insertAfter(element) error.wrap("<div class=\"form_error\">") } }); $(".courses").hide(); $("#course_select").change(function() { switch($(this).val()){ case "Certificates": $(".courses").hide().parent().find("#Certificates").show(); $(".filler").hide(); break; case "Associates": $(".courses").hide().parent().find("#Associates").show(); $(".filler").hide(); break; case "": $(".filler").show(); $(".courses").hide(); } }); }); And the HTML: <select id="course_select"> <option value="">Please Select</option> <option value="Certificates">Certificates</option> <option value="Associates">Associates</option> </select> <div id="Form0" class="filler"><select name="filler_select"><option value="">Please Select Course Type</option></select></div> <div id="Associates" class="courses"> <select name="lead_source_id" id="Requested Program" class="required"> <option value="">Please Select</option> <option value="01">Health Information Technology</option> <option value="02">Human Resources </option> <option value="03">Marketing </option> </select> </div> <div id="Certificates" class="courses"> <select name="lead_source_id" id="Requested Program" class="required"> <option value="">Please Select</option> <option value="04">Accounting Services</option> <option value="05">Bookkeeping</option> <option value="06">Child Day Care</option> </select> </div> So far, the select is working for me, but validation thinks that the field is empty even when a value is selected. It looks like there are a ton of ways to do conditional selects in jQuery. This was the best way I managed to work out (I'm new to jQuery), but I'd love to hear what you folks feel is the "best" way, especially if it works well with the validation plugin. Thanks!

    Read the article

  • Investigation: Can different combinations of components effect Dataflow performance?

    - by jamiet
    Introduction The Dataflow task is one of the core components (if not the core component) of SQL Server Integration Services (SSIS) and often the most misunderstood. This is not surprising, its an incredibly complicated beast and we’re abstracted away from that complexity via some boxes that go yellow red or green and that have some lines drawn between them. Example dataflow In this blog post I intend to look under that facade and get into some of the nuts and bolts of the Dataflow Task by investigating how the decisions we make when building our packages can affect performance. I will do this by comparing the performance of three dataflows that all have the same input, all produce the same output, but which all operate slightly differently by way of having different transformation components. I also want to use this blog post to challenge a common held opinion that I see perpetuated over and over again on the SSIS forum. That is, that people assume adding components to a dataflow will be detrimental to overall performance. Its not surprising that people think this –it is intuitive to think that more components means more work- however this is not a view that I share. I have always been of the opinion that there are many factors affecting dataflow duration and the number of components is actually one of the less important ones; having said that I have never proven that assertion and that is one reason for this investigation. I have actually seen evidence that some people think dataflow duration is simply a function of number of rows and number of components. I’ll happily call that one out as a myth even without any investigation!  The Setup I have a 2GB datafile which is a list of 4731904 (~4.7million) customer records with various attributes against them and it contains 2 columns that I am going to use for categorisation: [YearlyIncome] [BirthDate] The data file is a SSIS raw format file which I chose to use because it is the quickest way of getting data into a dataflow and given that I am testing the transformations, not the source or destination adapters, I want to minimise external influences as much as possible. In the test I will split the customers according to month of birth (12 of those) and whether or not their yearly income is above or below 50000 (2 of those); in other words I will be splitting them into 24 discrete categories and in order to do it I shall be using different combinations of SSIS’ Conditional Split and Derived Column transformation components. The 24 datapaths that occur will each input to a rowcount component, again because this is the least resource intensive means of terminating a datapath. The test is being carried out on a Dell XPS Studio laptop with a quad core (8 logical Procs) Intel Core i7 at 1.73GHz and Samsung SSD hard drive. Its running SQL Server 2008 R2 on Windows 7. The Variables Here are the three combinations of components that I am going to test:     One Conditional Split - A single Conditional Split component CSPL Split by Month of Birth and income category that will use expressions on [YearlyIncome] & [BirthDate] to send each row to one of 24 outputs. This next screenshot displays the expression logic in use: Derived Column & Conditional Split - A Derived Column component DER Income Category that adds a new column [IncomeCategory] which will contain one of two possible text values {“LessThan50000”,”GreaterThan50000”} and uses [YearlyIncome] to determine which value each row should get. A Conditional Split component CSPL Split by Month of Birth and Income Category then uses that new column in conjunction with [BirthDate] to determine which of the same 24 outputs to send each row to. Put more simply, I am separating the Conditional Split of #1 into a Derived Column and a Conditional Split. The next screenshots display the expression logic in use: DER Income Category         CSPL Split by Month of Birth and Income Category       Three Conditional Splits - A Conditional Split component that produces two outputs based on [YearlyIncome], one for each Income Category. Each of those outputs will go to a further Conditional Split that splits the input into 12 outputs, one for each month of birth (identical logic in each). In this case then I am separating the single Conditional Split of #1 into three Conditional Split components. The next screenshots display the expression logic in use: CSPL Split by Income Category         CSPL Split by Month of Birth 1& 2       Each of these combinations will provide an input to one of the 24 rowcount components, just the same as before. For illustration here is a screenshot of the dataflow containing three Conditional Split components: As you can these dataflows have a fair bit of work to do and remember that they’re doing that work for 4.7million rows. I will execute each dataflow 10 times and use the average for comparison. I foresee three possible outcomes: The dataflow containing just one Conditional Split (i.e. #1) will be quicker There is no significant difference between any of them One of the two dataflows containing multiple transformation components will be quicker Regardless of which of those outcomes come to pass we will have learnt something and that makes this an interesting test to carry out. Note that I will be executing the dataflows using dtexec.exe rather than hitting F5 within BIDS. The Results and Analysis The table below shows all of the executions, 10 for each dataflow. It also shows the average for each along with a standard deviation. All durations are in seconds. I’m pasting a screenshot because I frankly can’t be bothered with the faffing about needed to make a presentable HTML table. It is plain to see from the average that the dataflow containing three conditional splits is significantly faster, the other two taking 43% and 52% longer respectively. This seems strange though, right? Why does the dataflow containing the most components outperform the other two by such a big margin? The answer is actually quite logical when you put some thought into it and I’ll explain that below. Before progressing, a side note. The standard deviation for the “Three Conditional Splits” dataflow is orders of magnitude smaller – indicating that performance for this dataflow can be predicted with much greater confidence too. The Explanation I refer you to the screenshot above that shows how CSPL Split by Month of Birth and salary category in the first dataflow is setup. Observe that there is a case for each combination of Month Of Date and Income Category – 24 in total. These expressions get evaluated in the order that they appear and hence if we assume that Month of Date and Income Category are uniformly distributed in the dataset we can deduce that the expected number of expression evaluations for each row is 12.5 i.e. 1 (the minimum) + 24 (the maximum) divided by 2 = 12.5. Now take a look at the screenshots for the second dataflow. We are doing one expression evaluation in DER Income Category and we have the same 24 cases in CSPL Split by Month of Birth and Income Category as we had before, only the expression differs slightly. In this case then we have 1 + 12.5 = 13.5 expected evaluations for each row – that would account for the slightly longer average execution time for this dataflow. Now onto the third dataflow, the quick one. CSPL Split by Income Category does a maximum of 2 expression evaluations thus the expected number of evaluations per row is 1.5. CSPL Split by Month of Birth 1 & CSPL Split by Month of Birth 2 both have less work to do than the previous Conditional Split components because they only have 12 cases to test for thus the expected number of expression evaluations is 6.5 There are two of them so total expected number of expression evaluations for this dataflow is 6.5 + 6.5 + 1.5 = 14.5. 14.5 is still more than 12.5 & 13.5 though so why is the third dataflow so much quicker? Simple, the conditional expressions in the first two dataflows have two boolean predicates to evaluate – one for Income Category and one for Month of Birth; the expressions in the Conditional Split in the third dataflow however only have one predicate thus they are doing a lot less work. To sum up, the difference in execution times can be attributed to the difference between: MONTH(BirthDate) == 1 && YearlyIncome <= 50000 and MONTH(BirthDate) == 1 In the first two dataflows YearlyIncome <= 50000 gets evaluated an average of 12.5 times for every row whereas in the third dataflow it is evaluated once and once only. Multiply those 11.5 extra operations by 4.7million rows and you get a significant amount of extra CPU cycles – that’s where our duration difference comes from. The Wrap-up The obvious point here is that adding new components to a dataflow isn’t necessarily going to make it go any slower, moreover you may be able to achieve significant improvements by splitting logic over multiple components rather than one. Performance tuning is all about reducing the amount of work that needs to be done and that doesn’t necessarily mean use less components, indeed sometimes you may be able to reduce workload in ways that aren’t immediately obvious as I think I have proven here. Of course there are many variables in play here and your mileage will most definitely vary. I encourage you to download the package and see if you get similar results – let me know in the comments. The package contains all three dataflows plus a fourth dataflow that will create the 2GB raw file for you (you will also need the [AdventureWorksDW2008] sample database from which to source the data); simply disable all dataflows except the one you want to test before executing the package and remember, execute using dtexec, not within BIDS. If you want to explore dataflow performance tuning in more detail then here are some links you might want to check out: Inequality joins, Asynchronous transformations and Lookups Destination Adapter Comparison Don’t turn the dataflow into a cursor SSIS Dataflow – Designing for performance (webinar) Any comments? Let me know! @Jamiet

    Read the article

  • C# Conditional Compilation and framework targets

    - by McKAMEY
    There are a few minor places where code for my project may be able to be drastically improved if the target framework were a newer version. I'd like to be able to better leverage conditional compilation in C# to switch these as needed. Something like: #if NET_40 using FooXX = Foo40; #elif NET_35 using FooXX = Foo35; #else using FooXX = Foo20; #endif Do these symbols come for free? Do I need to inject these symbols as part of the project configuration? Seems easy enough to do since I'll know which framework is being targeted from msbuild. I think I've seen that NET_40 symbol isn't defined? If so I think I could do this? #if !NET_35 && !NET_20 #define NET_40 #endif Or do I need to define it in the msbuild command: /p:DefineConstants="NET_40"

    Read the article

  • pass value from embedded function into conditional of page the embedded function is included on

    - by Brad
    I have a page that includes/embeds a file that contains a number of functions. One of the functions has a variable I want to pass back onto the page that the file is embedded on. <?php include('functions.php'); userInGroup(); if($user_in_group) { print 'user is in group'; } else { print 'user is not in group'; } ?> function within functions.php <?php function userInGroup() { foreach($group_access as $i => $group) { if($group_session == $group) { $user_in_group = TRUE; break; } else { $user_in_group == FALSE; } } }?> I am unsure as to how I can pass the value from the function userInGroup back to the page it runs the conditional if($user_in_group) on Any help is appreciated.

    Read the article

  • Missing Java error on conditional expression?

    - by Federico Cristina
    With methods test1() and test2(), I get a Type Mismatch Error: Cannot convert from null to int, which is correct; but why am I not getting the same in method test3()? How does Java evaluates the conditional expression differently in that case? (obviusly, a NullPointerException will rise in runtime). Is it a missing error? public class Test { public int test1(int param) { return null; } public int test2(int param) { if (param > 0) return param; return null; } public int test3(int param) { return (param > 0 ? return param : return null); } } Thanks in advance!

    Read the article

  • PDO update query with conditional?

    - by dmontain
    I have a PDO mysql that updates 3 fields. $update = $mypdo->prepare("UPDATE tablename SET field1=:field1, field2=:field2, field3=:field3 WHERE key=:key"); But I want field3 to be updated only when $update3 = true; (meaning that the update of field3 is controlled by a conditional statement) Is this possible to accomplish with a single query? I could do it with 2 queries where I update field1 and field2 then check the boolean and update field3 if needed in a separate query. //run this query to update only fields 1 and 2 $update_part1 = $mypdo->prepare("UPDATE tablename SET field1=:field1, field2=:field2 WHERE key=:key"); //if field3 should be update, run a separate query to update it separately if ($update3){ $update_part2 = $mypdo->prepare("UPDATE tablename SET field3=:field3 WHERE key=:key"); } But hopefully there is a way to accomplish this in 1 query?

    Read the article

  • Update query with conditional?

    - by dmontain
    I'm not sure if this possible. If not, let me know. I have a PDO mysql that updates 3 fields. $update = $mypdo->prepare("UPDATE tablename SET field1=:field1, field2=:field2, field3=:field3 WHERE key=:key"); But I want field3 to be updated only when $update3 = true; (meaning that the update of field3 is controlled by a conditional statement) Is this possible to accomplish with a single query? I could do it with 2 queries where I update field1 and field2 then check the boolean and update field3 if needed in a separate query. //run this query to update only fields 1 and 2 $update_part1 = $mypdo->prepare("UPDATE tablename SET field1=:field1, field2=:field2 WHERE key=:key"); //if field3 should be update, run a separate query to update it separately if ($update3){ $update_part2 = $mypdo->prepare("UPDATE tablename SET field3=:field3 WHERE key=:key"); } But hopefully there is a way to accomplish this in 1 query?

    Read the article

  • Cell color change In Excel Using Conditional formatting in C#

    - by Suryakavitha
    Hi, I have exported datatable to excel successfully... Now i have to change some cell color using Conditional formatting in Excel sheet using C#.... For example if a cell contains text as "Cat" it should be display in Green color and if a cell contains text as "Dog" it should display in blue Color.... Now how can i do this ? Plz Anyone tell me the solution of this ... or give me the code for it... Thanks In Advance..

    Read the article

  • USing Min/Max with conditional operator

    - by user638501
    Hello All, I am trying to run a query to find max and min values, and then use a conditional operator. however when I try to run the following query, it gives me error - "misuse of aggregate: min()". My query is: SELECT a.prim_id, min(b.new_len*36) as min_new_len, max(b.new_len*36) as max_new_len FROM tb_first a, tb_second b WHERE a.sec_id = b.sec_id AND min_new_len > 1900 AND max_new_len < 75000 GROUP BY a.prim_id ORDER BY avg(b.new_len*36); Any suggestions ?

    Read the article

  • How can I support conditional validation of model properties

    - by Jeff
    I currently have a form that I am building that needs to support two different versions. Each version might use a different subset of form fields. I have to do this to support two different clients, but I don't want to have entirely different controller actions for both. So, I am trying to come up with a way to use a strongly typed model with validation attributes but have some of these attributes be conditional. Some approaches I can think of is similar to steve sanderson's partial validation approach. Where I would clear the model errors in a filter OnActionExecuting based on which version of the form was active. The other approach I was thinking of would to break the model up into pieces using something like class FormModel { public Form1 Form1Model {get; set;} public Form2 FormModel {get; set;} } and then we would validate appropriately depending on

    Read the article

  • How to do conditional comments in drupal?

    - by wamp
    <!-- Additional IE/Win specific style sheet (Conditional Comments) --> <!--[if IE]> <style type="text/css" media="all">@import "files/tabs-ie.css";</style> <script type="text/javascript" src="files/DOMAssistantCompressed-2.7.4.js"></script> <script type="text/javascript" src="files/ie-css3.js"></script> <![endif]--> .. <!--[if IE 7.0]> <link rel="stylesheet" href="files/ie-7.css" type="text/css" media="all" charset="utf-8" /> <![endif]--> How to do the above in drupal?

    Read the article

  • StructureMap 'conditional singleton' for Lucene.Net IndexReader

    - by Gareth D
    I have a threadsafe object that is expensive to create and needs to be available through my application (a Lucene.Net IndexReader). The object can become invalid, at which point I need to recreate it (IndexReader.IsCurrent is false, need a new instance using IndexReader.Reopen). I'd like to able to use an IoC container (StructureMap) to manage the creation of the object, but I can't work out if this scenario is possible. It feels like some kind of "conditional singleton" lifecycle. Does StructureMap provide such a feature? Any alternative suggestions?

    Read the article

  • Conditional Required Attribute for validation

    - by jeriley
    We're trying to get a conditional attribute to work, case in point, there's a boolean (checkbox) that if checked, its related text is required. So, ideally we'd have something like ... public bool Provision { get; set; } [ConditionalRequirement(IsNeededWhenTrue = Provision)] public string ProvisionText { get; set; } Is this even possible? Alternate idea (not as elegant?) public bool Provision2 { get; set; } [PropertyRequired(RequiredBooleanPropertyName = "Provision2")] public string Provision2Text { get; set; } I'd hate to use the magic string method ... but any other ideas?

    Read the article

  • Problem using Conditional Operation with Nullable Int

    - by Rajarshi
    A small problem. Any idea guys why this does not work? int? nullableIntVal = (this.Policy == null) ? null : 1; I am trying to return 'null' if the left hand expression is True, else 1. Seems simple but gives compilation error - Type of conditional expression cannot be determined because there is no implicit conversion between 'null' and 'int' If I replace the " ? null : 1 " with any valid int, then there is no problem.

    Read the article

  • SQL Server 2008 - Conditional Query

    - by Villager
    Hello, SQL is not one of my strong suits. I have a SQL Server 2008 database. This database has a stored procedure that takes in eight int parameters. For the sake of keeping this question focused, I will use one of these parameters for reference: @isActive int Each of these int parameters will be -1, 0, or 1. -1 means "Unknown" or "Don't Care". Basically, I need to query a table such that if the int parameter is NOT -1, I need to consider it in my WHERE clause. Because there are eight int parameters, an IF-ELSE statement does not seem like a good idea. At the same time, I do not know how else to do this? Is there an elegant way in SQL to add a WHERE conditional if a parameter does NOT equal a value? Thank you!

    Read the article

  • Need to create regular expression in Javascript to check the valid conditional string

    - by user1796078
    I want to create the regular expression in javascript which will check the valid conditional string like -1 OR (1 AND 2) AND 1 -1 OR (1 AND 2) -1 OR 2 -1 OR 1 OR 1 -1 AND 1 AND 1 The string should not contain 'AND' and 'OR'. For example - 1 OR 2 AND 3 is invalid. -It should be (1 OR 2) AND 3 or 1 or (2 AND 3). I tried the following Regex. It works for most of the conditions but it is failing to check the above condition. /^(\s*\(\d+\s(AND|OR)\s\d+\)|\s*\d+)((\s*(AND|OR)\s*)(\(\d+\s(AND|OR)\s\d+\)|\s*\d+))*$/ Can anyone please help me to sort out the above problem.

    Read the article

  • Conditional jump or move depends on uninitialised value - freeing a linked list

    - by user720491
    I want to free a linked list in C. All is working fine, but Valgrind is telling me Conditional jump or move depends on uninitialised value(s) at 0x401400: mtf_destroy Here's the code: list_elt *head; void mtf_init() { list_elt *current; head = malloc(sizeof(list_elt)); current = head; for (int i = 0; i < LIST_SIZE-1; i++) { current->value = (BYTE) i; current->next = malloc(sizeof(list_elt)); current = current->next; } current->value = LIST_SIZE-1; } void mtf_destroy(list_elt *elt) { if (elt->next != NULL) mtf_destroy(elt->next); free(elt); } How can I solve this? Thanks!

    Read the article

  • Excel 2007 Format Row of Cells containing certain text

    - by paradox
    I am attempting to perform conditional formatting in Excel 2007 by checking if a cell has a specific string in it and therefore highlighting the entire row corresponding to the text. However, Excel 2007's Conditional Formatting only allows me to highlight that specific cell. Is there a workaround to this without having to get my hands dirty with VBA?

    Read the article

  • Conditional Regular Expression testing of a CSV

    - by Alastair Pitts
    I am doing some client side validation in ASP.NET MVC and I found myself trying to do conditional validation on a set of items (ie, if the checkbox is checked then validate and visa versa). This was problematic, to say the least. To get around this, I figured that I could "cheat" by having a hidden element that would contain all of the information for each set, thus the idea of a CSV string containing this information. I already use a custom [HiddenRequired] attribute to validate if the hidden input contains a value, with success, but I thought as I will need to validate each piece of data in the csv, that a regular expression would solve this. My regular expression work is extremely weak and after a good 2 hours I've almost given up. This is an example of the csv string: true,3,24,over,0.5 to explain: true denotes if I should validate the rest. I need to conditionally switch in the regex using this 3 and 24 are integers and will only ever fall in the range 0-24. over is a string and will either be over or under 0.5 is a decimal value, of unknown precision. In the validation, all values should be present and at least of the correct type Is there someone who can either provide such a regex or at least provide some hints, i'm really stuck!

    Read the article

  • Conditional alternative table row styles in HTML5

    - by Budda
    Is there any changes regarding this questions Conditional alternative table row styles since HTML5 came in? Here is a copy of original question: Is it possible to style alternate table rows without defining classes on alternate tags? With the following table, can CSS define alternate row styles WITHOUT having to give the alternate rows the class "row1/row2"? row1 can be default, so row2 is the issue. <style> .altTable td { } .altTable .row2 td { background-color: #EEE; } </style> <table class="altTable"> <thead><tr><td></td></tr></thead> <tbody> <tr><td></td></tr> <tr class="row2"><td></td></tr> <tr><td></td></tr> <tr class="row2"><td></td></tr> </tbody> </table> Thanks a lot!

    Read the article

  • Error C2451: Illegal conditional expression of type 'UnaryOp<E1, Op>' in ostream - visual studio 9

    - by Steven Hill
    I am getting a repeated error with VS 9. The code compiles under GNU C++, but I want debug with the VS IDE. Any idea what could be causing this error. Error 13 error C2451: conditional expression of type 'UnaryOp' is illegal \Microsoft Visual Studio 9.0\VC\include\ostream 512 //unary constraint template class UnaryOp : public Constraint { public: const E1& e1; UnaryOp(const E1& _e1); bool Satisfiable() const; Bool SatisfiableAux() const; void Print (std::ostream& os) const; UnaryOp* clone () const; //operator bool () const { return true; } }; template std::ostream& operator<<(std::ostream& os, const UnaryOp& unop); UnaryOp code that uses ostream: template INLINE void UnaryOp::Print (std::ostream& os) const { os << *this; } template INLINE std::ostream& operator<<(std::ostream& os, const UnaryOp& unop) { return os << Op::name << unop.e1; } ostream line with error: _Myt& __CLR_OR_THIS_CALL put(_Elem _Ch) { // insert a character ios_base::iostate _State = ios_base::goodbit; const sentry _Ok(*this); 512 if (!_Ok) _State |= ios_base::badbit; else { // state okay, insert character _TRY_IO_BEGIN

    Read the article

  • Conditional required field validation in an ASP.net ListView

    - by Jim Dagg
    I'm having a heck of a time trying to figure out how to implement validation in a ListView. The goal is to require the user to enter text in the comments TextBox, but only if the CheckBox is checked. Downside is that these controls are in the EditTemplate of a ListView. Below is a snippet of the relevant code portion of the EditTemplate: <tr style="background-color: #00CCCC; color: #000000"> <td> Assume Risk? <asp:CheckBox ID="chkWaive" runat="server" Checked='<%# Bind("Waive") %>' /> </td> <td colspan="5"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Comments required" ControlToValidate="txtComments" /> <asp:TextBox Width="95%" ID="txtComments" runat="server" Text='<%# Eval("Comment") %>'></asp:TextBox> </td> <td> <asp:Button ID="btnSave" runat="server" Text="Save" CommandName="Update" Width="100px" /> </td> </tr> Is there a way to do conditional validation using this method? If not, is there a way I could validate manually in the ItemUpdating event of the Listview, or somewhere else, and on a failure, alert the user of the error via a label or popup alert?

    Read the article

  • Type-conditional controls in Haskell

    - by estanford
    I'm going through the 99 Haskell problems to build my proficiency with the language. On problem 7 ("Flatten a nested list structure"), I found myself wanting to define a conditional behavior based on the type of argument passed to a function. That is, since *Main> :t 1 1 :: (Num t) => t *Main> :t [1,2] [1,2] :: (Num t) => [t] *Main> :t [[1],[2]] [[1],[2]] :: (Num t) => [[t]] (i.e. lists nested at different levels have different data types) it seems like I should be able to write a function that can read the type of the argument, and then behave accordingly. My first attempt was along these lines: listflatten l = do if (:t l) /= ((Num t) => [t]) then listflatten (foldl (++) [] l) else id l But when I try to do that, Haskell returns a parse error. Is Haskell flexible enough to allow this sort of type manipulation, do I need to find another way?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >