Is there an example to use interface to replace if then else pattern in F#

is there an example to use interface to replace if then else pattern in F#
i want to make match pattern with only one rule to represent dynamic number of rules which is use 
let rec fun1 m number fun2param =
    match m with
    | fun2param(a,b,number) -> ****rewrite terms ****
let fun2param number =
    if number = 1 then
             function.....
    elif number = 2 then
            function ....
computing nightmare

In general, you use a match
let fun2param number =
match number with
| 1 -> function.....
| 2 -> function ....
in the same way as you would use a `switch` construct in 'C' in place of a repeated if/elif...elif/else
Your request is somewhat vague, so I'm not sure whether you would benefit from wrapping that behind an active pattern.

Similar Messages

  • Are there any examples for using a CAN card via XNET on a real time system?

    I am programming a real time application and I have a PXI 8512 card.  My first order of business is to get 5-byte messages from transducers that are broadcasting at 10 Hz on known message IDs.  There are no CAN/XNET samples in my "realtime" CVI sample folder.  I have found some in the nixnet folder but they are Windows based so I have to hack a lot of stuff out of them.
    Thank you.
    Michael Chadwell
    Department of Engine and Vehicle R&D
    Southwest Research Institute

    In other words, I just need to do something very similar to this with no user interface:
    NOTE: See attachment
    Michael Chadwell
    Department of Engine and Vehicle R&D
    Southwest Research Institute
    Attachments:
    CAN Bus Monitor.jpg ‏83 KB

  • Is there a way to use the find/replace tool to select the actual step in the TestStand sequence instead of just listing matching values in the find window?

    The purpose of this is to be able to select many steps that are scattered throughout a sequence so I can change the step type one time.  I could do this now, but it would take me 30 minutes to click through the sequence and select all of the steps before I'd even change the step type because there are different steps inbetween the ones I want to select.  I wouldn't be able to just use the shift key to select multiple steps because of that.  I have about 500 steps I need to select, so it would be worth it to find an automated way to do that.
    Unless there's a way to change a step type from a numericlimittest to an action step type from the find/replace window???

    I ended up using ActiveX calls in TestStand to find the steps I wanted and change the step type to Action.  See attached example sequence.
    Attachments:
    Convert NumericLimitTest to Action step type example.seq ‏9 KB

  • [BIP Report] Could I use 'like' syntax inside if-then-else statement?

    I have the following contents in my xml, I would like to show the amount of the ChargeAmount, only if the "Code" is starting from "WAF"in my table.
    <Transaction>
         <Account>A</Account>
         <ChargeAmount>200</ChargeAmount>
         <Code>WAF020</Code>
    </Transaction>
    <Transaction>
         <Account>B</Account>
         <ChargeAmount>250</ChargeAmount>
         <Code>WAF003</Code>
    </Transaction>
    <Transaction>
         <Account>C</Account>
         <ChargeAmount>120</ChargeAmount>
         <Code>WNL012</Code>
    </Transaction>
    <Transaction>
         <Account>D</Account>
         <ChargeAmount>200</ChargeAmount>
         <Code>WNL002</Code>
    </Transaction>
    *** Note that the three digits after WAF is variable.
    Display Table:
    Account || ChargeAmount || Code
    A|| 200 ||WAF020
    B|| 250 ||WAF003
    C|| NULL ||NULL
    D|| NULL ||NULL
    In the ChargeAmount column I tried the following syntax, however, both of them does not work well.
    <?if: <xdoxslt:left(Code, 3)>  = 'WAF' ?> then ChargeAmount else ' ' ?end if?>
    <?xdofx if: Code  = 'WAF?' ?> then ChargeAmount else ' ' ?end if?>
    Could any expert provide work around for the above case?
    Thanks!
    Connie

    In the ChargeAmount column I tried the following syntax, however, both of them does not work well.
    <?if: <xdoxslt:left(Code, 3)>  = 'WAF' ?> then ChargeAmount else ' ' ?end if?>
    <?xdofx if: Code  = 'WAF?' ?> then ChargeAmount else ' ' ?end if?>
    incorrect code will not work
    not clear what do you want to do but try
    <?xdoxslt:ifelse(xdoxslt:left(Code,3)='WAF',’yes’,’no’)?>
    or
    <?xdoxslt:ifelse(contains(Code, 'WAF'),’yes’,’no’)?>

  • Any Examples of using ActiveCollectionModelDecorator with POJO data control

    Are there any Examples of using ActiveCollectionModelDecorator with POJO data control in any of the sample packs?

    OK, here's an quick example. Create a new Windows Forms application and add a ScatterGraph and a Label to the form. Add a cursor to the ScatterGraph, then add the code below to the form. This generates 50 random data points when the form is loaded and plots them, then uses the cursor's AfterMove event to display the current X and Y positions in the label. Here's the code:
    Private Sub OnFormLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Const dataLength As Integer = 50
    Dim xData(dataLength - 1) As Double
    Dim yData(dataLength - 1) As Double
    Dim rnd As Random = New Random
    For i As Integer = 0 To dataLength - 1
    xData(i) = i
    yData(i) = rnd.NextDouble() * 10
    Next
    ScatterGraph1.PlotXY(xData, yData)
    End Sub
    Private Sub OnAfterMoveXYCursor(ByVal sender As Object, ByVal e As NationalInstruments.UI.AfterMoveXYCursorEventArgs) Handles XyCursor1.AfterMove
    Label1.Text = String.Format("({0}, {1})", e.XPosition, e.YPosition)
    End Sub
    Hope this helps.
    - Elton

  • I have Photoshop CS2 but I had to get my computer fixed which means I lost it..when I try to download it from the website it stops at 173of340...I have my original cd is there anyway I can use it and put in a different serial number

    I have Photoshop CS2 but my computer crashed on me which means I lost it..when I try to download it from adobe web site it stops at 173/340...is there anyway I can use my original CD and then  use a different serial number

    No, you have the web site version because this applies:
    Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3
    The rest we cannot know. You have not provided any system information or details like what browser you use, so nobody can help you with your technical issues.
    Mylenium

  • Is there any  example snippet for XPath using namespace

    Hi,
    I have used XpathApi class to get the XML node matching my xpath that does not deal with namespaces and it works for me. However, it does not seem to work well when I construct the xpath with namespaces (probably I may be doing something wrong example: //ns:node1/@ns:attr1).
    Can anyone give pointers or some example snippet or some links to handle Xpath with namespaces.
    Also if there is any better approach (Classes or framework) for handing XPath with namespaces then please let me know.
    Thanks,
    -vc

    AnkitG wrote:
    Hi All,
    Is there any example for N9010A EXA signal analyzer , I tried to use example of MXA got from the driver page but couldnt get to work. I need to capture the RF data form the analyzer. Please let me know if there any example or way to do it.
    That is an Agilent instrument. Shouldn't be looking for examples on THEIR website?????

  • Code example using interface controller ?

    Hi, guys:
    I have a question.
    In CRM UI, I need to integrate one component with another component, and I want to pass the value from 1st component to 2nd component using interface controller. Does any one who have done this before and have a code example?
    Really appreciate!
    Eric

    Hi Eric,
    Refer:
    [http://forums.sdn.sap.com/thread.jspa?threadID=2014259|http://forums.sdn.sap.com/thread.jspa?threadID=2014259]
    [http://forums.sdn.sap.com/thread.jspa?threadID=1909625|http://forums.sdn.sap.com/thread.jspa?threadID=1909625]
    Regards,
    Leon

  • There's any example of using the gateway plugin functionality?

    Hello again!!! xD
    There's any example of using the gateway plugin functionality?

    To put your custom media element loaded from a plugin on the stage, you can use a MediaContainer object:
    var adContainer:MediaContainer;
    adContainer.width = 468;
    adContainer.height = 60;
    adContainer.addMediaElement(adElement);
    addChild(adContainer); // assuming we're on a Sprite.
    The video element can be in its own container:
    var videoContainer:MediaContainer;
    videoContainer.width = 468;
    videoContainer.height = 60;
    videoContainer.addMediaElement(videoElement);
    addChild(videoContainer);
    Regardless of wheter or not the adElement and videoElement are in a parallel element together, each indiviual view will appear in the assigned container.
    Does that anwer your question?
    Cheers,
    Edwin

  • What is difference between using interface as source and table as source?

    I am working on a batch flow which need several steps to populate data from source to target. For example, I need 5 interfaces to finish final data loading. I can either use interface or use temporary table as source and target for the interface 2, 3, and 4. It looks like both case will use tables no matter use interface or use temporary table. So my question is if there is any difference between these two (using interface as source or use temporary table as source)?
    Thanks

    if you use a Table as source for the intermediate process, it will create a physical temporary table i your work rep(depends on you choice) and populate the data into the table. if you use a interface as a source, just it will create a sub query instead of temporary table.
    Thanks
    nidhi

  • How to instantiate a control in code instead of using Interface Builder ?

    I really appreciate the combination of the interface builder and Xcode altogether.
    However when I am learning QT, I realize I had been pampered by Apple's Design to a certain extend as I only need to create say a NSLabel instance and use Interface Builder to do the linking and never have to worry about instantiating the Object myself.
    But I'm curious, what is the way to instantiate a new hmmm say...NSLabel in the code ?
    NSLabel* label = new NSLabel();
    Then what ?
    What you are seeing here is how QT did it, could anyone create an equivalent in ObjC ? No fancy code please, just bare minimum.
    #include <QApplication>
    #include <QWidget>
    #include <QLabel>
    int main (int argc, char * argv [ ])
    QApplication app(argc, argv); //NSApplication in ObjC
    //These two lines merely created a window and set the title bar text.
    QWidget* window = new QWidget();
    window->setWindowTitle("Hello World");
    QLabel* label = new QLabel(window);//Create a label and inform the it belongs to window.
    label->setText("Hello World");
    window->show();
    return app.exec();
    Message was edited by: Bracer Jack

    Hi Jack -
    I think my best answer will be something of a disappointment, because I don't know how to show a one-to-one correspondence between the code you're working with and a Cocoa program. The main function of a Cocoa GUI program for OS X will look something like this:
    #import <Cocoa/Cocoa.h>
    int main(int argc, char *argv[])
    return NSApplicationMain(argc, (const char **) argv);
    As you commented, we could draw a correspondence between the first statements, but after that the functionality of the Cocoa program is going to be spread out in a way that makes for a rather tedious comparison. The only way I know to answer your question in less than 5000 words, is to skip ahead to one of several points in the startup sequence where the programmer can intervene with custom code.
    For example, a common way to get control would be to program a custom controller class and add an object of that class to the main nib file which is loaded during the startup sequence. By making a connection to the Application object in that nib file, the custom object could be made the delegate of the Application object, and if we then added a method named applicationDidFinishLaunching, our code would run as soon as the application's run loop was started.
    Now I finally have enough context to directly answer your question, so here is the code to create a label and add it to the key window at launch time:
    // MyAppController.m
    #import "AppController.h"
    @implementation AppController
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    NSLog(@"applicationDidFinishLaunching");
    NSRect frameRect = NSMakeRect(150, 300, 150, 30);
    NSTextField *label = [[NSTextField alloc] initWithFrame:frameRect];
    [label setEditable:NO];
    [label setStringValue:@"Hello World!"];
    [label setFont:[NSFont labelFontOfSize:20]];
    [label setAlignment:NSCenterTextAlignment];
    NSView *contentView = [self.window contentView];
    [contentView addSubview:label];
    @end
    If I needed to develop a worst case scenario for this thread, the next question would be, "Ok sure, but your code still needs a nib to start up. I want to see a Cocoa GUI program that doesn't require any nib".
    It turns out that it's quite easy to build a simple iPhone app without any nib, but it's considerably more difficult for an OS X app. If anyone wants to see my nib-less iPhone code, I'll be happy to post it (I think I did post it here once before, and the response was underwhelming). But I've never attempted the much more difficult nib-less OS X app. Just in case you really want to go there, here's a blog that goes into the details: [http://lapcatsoftware.com/blog/2007/07/10/working-without-a-nib-part-5-open-re cent-menu>.
    Hope some of the above is helpful!
    - Ray

  • What is the advantages of using Interface?

    Hi,
    I still don't get what's the advantages of using interface. Reusability? is it the main advantage? thanks in advance.

    What is GOF?
    Interface is a good program practice when working with RMI (Remote Method Invocation) application. Imagine your anti-virus. When you connect to internet your software invoke a method into your software vendor site and download the new definitions. Now every anti-virus Subscription is different. The method you invoke, will depends on your Subscription. If you hard code the method abstractly, you will not achieve this functionality.
    Another concept is that because Java does not practice multile inheritance interface is a goog way to interface into another class.
    Example
    I want to extends to multiple class which java do not support. I will write an interface i.e I want to extends to FileOutputStream, OutputStream, Object, Integer, String, ActionEvent, Window etc.
    I will write an interface like this
    interface MyClass {
    pulic void setFileOutputStream ( FileOutputStream file );
    public void setOutputStream ( OutputStream );
    public Object getObject ( );
    public Seriable getInterget ( )
    ------------------- //You get the gist
    With this interface you can implement they behaviours
    You could say, why don't we just import them. When yo import them you have already hard coded there behaviour. But this way you can apply diferent behaviour throughout you application development. And any class that implement them must provide ways of using it.

  • Why not use interfaces for constants?

    Hi,
    I have been getting conflicting views about why not use interfaces for constants?
    Can anyone shed some light on it?
    Piyush

    How so?
    If the constants are only used in a single classhow
    does it help to put them in a separate structute?
    (Ignoring the a type safe enumeration of course.)Well, mainly for readability. Suppose that you have a
    web application which has a servlet class
    "RedirectServlet", which takes a variable to redirect
    to a given JSP file. In the JSP files, you want to
    create forms which take this servlet as their action.
    You could of course put all these "redirect"
    constants in the RedirectServlet itself, but then
    it's kind of weird that you have to import a
    servlet in your jsp file to include these constants
    and to be able to write
    <form action="servlet/RedirectServlet?key=<%=
    RedirectServlet.HOMEPAGE %>> or so.
    Instead, you could create an interface called
    "RedirectConstants", and then your servlet
    RedirectServlet could implement this interface. Then
    your JSP can also access these constants via this
    interface.
    But then again, this is merely a matter of style, I
    fully agree that there is never a real _need_ to put
    constants in a separate structure if they're only used
    in a single class.Are you claiming that your example above is a single class?

  • Import Receiving manually by using ROI  (using interface).

    Hi all,
    I'm trying to build a program about Receiving.
    I insert the data in  RCV_HEADERES_INTERFACE and RCV_TRANSACTIONS_INTERFACE
    after i commit the SQL. i execute Receiving Transaction Processor to process my data.
    the data in RCV_TRANSACTIONS_INTERFACE is success
    but  the data in RCV_HEADERES_INTERFACE  return ERROR.
    the receiving shipment number I'm testing is already received part of the item from using standard form
    example:   total quantity is 5000.   we use standard form received 1000 and there still 4000 are waiting for received .
    in this condition, if next time we use Interface to Received the remaining item.
    should i insert the data in RCV_HEADERES_INTERFACE ?
    or just insert line's data in RCV_TRANSACTIONS_INTERFACE?
    thanks
    Please help.

    Following is the sample script . It is used to take the receipt very first time.
    INSERT INTO rcv_headers_interface
              (  header_interface_id
               , group_id
               , processing_status_code
               , receipt_source_code
               , transaction_type
               , vendor_id
               , vendor_site_id
               , validation_flag
               , expected_receipt_date
               , shipment_num
               , shipped_date
               , packing_slip
               , attribute_category          
               , attribute1
               , attribute2
               , attribute3                                                                     
               , attribute13
               , last_update_date
               , last_updated_by
               , last_update_login
               , creation_date
               , created_by
          SELECT rcv_headers_interface_s.NEXTVAL
               , rcv_interface_groups_s.NEXTVAL
               , 'PENDING'     -- Processing_Status_Code
               , 'VENDOR'      -- Receipt_Source_Code,
               , 'NEW'         -- Transaction_Type        
               ,  v_vendor_id  -- vendor_id
               ,  v_vend_site_id  -- vendor_site_id           
               , 'Y'           -- Validation_Flag
               ,  SYSDATE      -- Expected_Receipt_Date
               ,  p_ship_num   --'Shipment_Num
               ,  SYSDATE      -- Shipment_Date
               ,  p_pack_slip_no --'Packing_Slip 
               , 'India Receipt' -- Attribute Category           
               ,  p_excise_num  --' Excise Invoice No.
               ,  TO_CHAR(SYSDATE, 'DD-MON-YYYY')       -- Excise Invoice Date
               , 'Y'           -- Claim Cenvat on Receipt
               ,  'VAT'        -- Attribute13
               , SYSDATE       -- last_update_date
               , p_user_id     -- last_updated_by
               , p_user_id     -- last_update_login  
               , SYSDATE       -- creation_date
               , p_user_id     -- created_by
         FROM DUAL;

  • Looking for example to use Aerotech Solist CP motor in CVI

    Hi all,
      Is there any example to drive Aerotech's Soloist CP motor in CVI? I found a labview code for Soloist CP in the installation directory. I used that with labview before but now I am porting lal code to CVI, I have no idea how to make it work in CVI.

    RobertoBozzolo wrote:
    You need to study the documentation that comes with your device and the interfacing possibilities the device offers. If the driver comes with a DLL than you could try using DLL functions directly in CVI: this document offers some explanations on how to realize this part, in any case the DLL must come with some include file that declares functions and types to use. You can also search in the support site or in the forums for additional documents or examples.
    The LabVIEW driver itself could be an interface to the DLL, so if you have some familiarity with LV you could try looking at the underlyning code to see what's in it.
    Having said this, I have never used devices from that producers so I cannot be of much help in using them.
    Hi RobertoBozzolo,
      With your suggestion, I've compiled the vi to DLL. For testing, I write a code in c to call it and compile with gcc mingw32. It seems ok. But in the environment of labwindows/CVI, I don't have other compiler other than CVI. So following this post http://digital.ni.com/public.nsf/allkb/70995EC2CA1B523386256DD4004F3DE6?OpenDocument, I have the DLL and the related header files copied to the same folder as the CVI program in. I should state that the DLL from Vi was compiled in other computer have labview 7.1 installed, it is running 32bits windows xp. But in the development environment (where I compiled the CVI), I am runing 2012 version in 64bit operating system. I don't know will that cause any conflict. But as directed in that page, I copy all headers in cintools from the LV7.1 computer, but when I compile it, it is said that " "fundtypes.h"(116,20)   Redeclaration of 'int64'." I have no idea how to fix this issue then
    Well, anyway, I comment out the definition of int64 in fundtypes.h and it finally compiled. However, since the DLL was compiled from LV7.1, when I run the compiled application with functions calling from the DLL, I got an error message that labview 7.1 runtimes required. Well, it is not a good idea to ask the client to install LV7.1 (runtime) just for running our application. So is that possible to compile the DLL and linking everything into the DLL so it doesn't require runtime 7.1? or any other suggestion?

Maybe you are looking for

  • [Solved] No longer able to boot Kernel

    Haven't been able to post this since I've been without internet for a time. Since the update requiring manual intervention on /etc/mtab (20th Dec, in the news feed) I have been unable to boot the kernel. Exact output is due to come (will have to try

  • Openbox and borders

    Hey guys, I am trying to set windows up in Openbox to have borders without decorations - I cant seem to get it to work though. The settings I've adjusted suggest it should work but for some reason the borders still dont work without decor. I've set u

  • Search an of objects for a string

    I have an array which contains phone objects..each object contains lastname, firstname, address and telnumber. eg array called entry has values entry[2] = ('smith', 'paul' , '44 test st' , '123456) and so on for each cell in the array. How do I write

  • Xcelsius Problems

    Posting to make my problems known since they are not in the "known issues" post and there is no solution for them on any other posts. Problem # 1 - The spinners do not display other formats besides numbers. Problem # 2 - There is an error displaying

  • Add note in PC

    So it appears to me that the note's sync feature in outlook is yet another feature that does not "Just Work". I can create a note on my device (iphone) and it shows up in my iCloud folder in the notes folder.  Looks like a email to me (outlook integr