Search Results

Search found 166 results on 7 pages for 'acc'.

Page 2/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • F#: Tell me what I'm missing about using Async.Parallel

    - by JBristow
    ok, so I'm doing ProjectEuler Problem #14, and I'm fiddling around with optimizations in order to feel f# out. in the following code: let evenrule n = n / 2L let oddrule n = 3L * n + 1L let applyRule n = if n % 2L = 0L then evenrule n else oddrule n let runRules n = let rec loop a final = if a = 1L then final else loop (applyRule a) (final + 1L) n, loop (int64 n) 1L let testlist = seq {for i in 3 .. 2 .. 1000000 do yield i } let getAns sq = sq |> Seq.head let seqfil (a,acc) (b,curr) = if acc = curr then (a,acc) else if acc < curr then (b,curr) else (a,acc) let pmap f l = seq { for a in l do yield async {return f a} } |> Seq.map Async.RunSynchronously let pmap2 f l = seq { for a in l do yield async {return f a} } |> Async.Parallel |> Async.RunSynchronously let procseq f l = l |> f runRules |> Seq.reduce seqfil |> fst let timer = System.Diagnostics.Stopwatch() timer.Start() let ans1 = testlist |> procseq Seq.map // 837799 00:00:08.6251990 printfn "%A\t%A" ans1 timer.Elapsed timer.Reset() timer.Start() let ans2 = testlist |> procseq pmap printfn "%A\t%A" ans2 timer.Elapsed // 837799 00:00:12.3010250 timer.Reset() timer.Start() let ans3 = testlist |> procseq pmap2 printfn "%A\t%A" ans3 timer.Elapsed // 837799 00:00:58.2413990 timer.Reset() Why does the Async.Parallel code run REALLY slow in comparison to the straight up map? I know I shouldn't see that much of an effect, since I'm only on a dual core mac. Please note that I do NOT want help solving problem #14, I just want to know what's up with my parallel code.

    Read the article

  • new line in a multi-line string

    - by Zka
    Trying to override a tostring in one of my classes. return string.Format(@" name = {0} ID = {1} sec nr = {2} acc nr = {3}", string, int, int ,int); // types But the thing is, the result isn't aligned when printed out: name = test ID = 42 sec nr = 11 acc nr = 55 Trying to add \n just prints it out without formating. Guessing it has something to do with @"" which I'm using for multi-lining. Would like it to print out : name = test ID = 42 sec nr = 11 acc nr = 55

    Read the article

  • error with string list in C#

    - by Chelsea_cole
    Same namespace: 2 forms. public class Account //frm1 { public string Username; public string Password; } public class ListAcc { public static List<Account> UserList; } private void button1_Click(object sender, EventArgs e) { List<Account> UserList = new List<Account>(); Account acc = new Account(); acc.Username = textBox1.Text; acc.Password = textBox2.Text; UserList.Add(acc); } private void button2_Click(object sender, EventArgs e) //frm2 { string p = frmDangky.ListAcc.UserList[0].Username; // null ->error string p = frmDangky.ListAcc.UserList[0].Password; // null ->error } Someone help me? :( why my string is NULL???????? The textBox is not empty... Thanks!

    Read the article

  • Selecting child element

    - by ScG
    I have the following div <div id="acc"> <a href="#">Link 1</a> <div> Some Content </div> <a href="#">Link 2</a> <div> Some Content </div> </div> All the div's are collapsed to start with. How can I select the first div child of 'acc' and say Slide Down on it I have cached the selector like this: var $acc = $(acc);

    Read the article

  • error string list handle in C#

    - by Chelsea_cole
    Same namespace: 2 forms. public class Account //frm1 { public string Username; public string Password; } public class ListAcc { public static List<Account> UserList; } private void button1_Click(object sender, EventArgs e) { List<Account> UserList = new List<Account>(); Account acc = new Account(); acc.Username = textBox1.Text; acc.Password = textBox2.Text; UserList.Add(acc); } private void button2_Click(object sender, EventArgs e) //frm2 { string p = frmDangky.ListAcc.UserList[0].Username; // null ->error string p = frmDangky.ListAcc.UserList[0].Password; // null ->error } Someone help me? :( why my string is NULL???????? The textBox is not empty... Thanks!

    Read the article

  • What's some simple F# code that generates the .tail IL instruction?

    - by kld2010
    I'd like to see the .tail IL instruction, but the simple recursive functions using tail calls that I've been writing are apparently optimized into loops. I'm actually guessing on this, as I'm not entirely sure what a loop looks like in Reflector. I definitely don't see any .tail opcodes though. I have "Generate tail calls" checked in my project's properties. I've also tried both Debug and Release builds in Reflector. The code I used is from Programming F# by Chris Smith, page 190: let factorial x = // Keep track of both x and an accumulator value (acc) let rec tailRecursiveFactorial x acc = if x <= 1 then acc else tailRecursiveFactorial (x - 1) (acc * x) tailRecursiveFactorial x 1 Can anyone suggest some simple F# code which will indeed generate .tail?

    Read the article

  • nginx php5-fpm "File not found" -- FastCGI sent in stderr: "Primary script unknown"

    - by jmfayard
    so I'm trying to run for the first time the nginx web server with php5-fpm on a debian wheezy server Hitting a php file display simply File not found I have done my research (waste a lot of hours actually ;), there are a lot of people that have similar problems, yet I didn't succeed to correct it with what worked for them. I still have the same error : $ tail /var/log/nginx/access.log /var/log/nginx/error.log /var/log/php5-fpm.log | less == /var/log/nginx/error.log <== 2013/10/26 21:36:00 [error] 6900#0: *1971 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, I have tried a lot of things, it's hard to remember what. I have put my config files on github my /etc/nginx/nginx.conf my /etc/php5/fpm/php-fpm.conf Currently, the nginx.conf configuration uses this... server { server_name mydomain.tld; root /srv/data1/test; location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } /etc/php5/fpm/pool.d/www.conf contains listen = 127.0.0.1:9000 I have tried the unix socket version, same thing. fastcgi_pass unix:/var/run/php5-fpm.sock; I made sure the server is started $ netstat -alnp | grep LISTEN tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 6913/php-fpm.conf) tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 4785/mysqld tcp 0 0 0.0.0.0:842 0.0.0.0:* LISTEN 2286/inetd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2812/rpcbind tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5710/nginx tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2560/sshd tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 5710/nginx tcp6 0 0 :::111 :::* LISTEN 2812/rpcbind unix 2 [ ACC ] STREAM LISTENING 323648 6574/tmux /tmp//tmux-1000/default unix 2 [ ACC ] STREAM LISTENING 619072 6790/fcgiwrap /var/run/fcgiwrap.socket unix 2 [ ACC ] SEQPACKET LISTENING 323 464/udevd /run/udev/control unix 2 [ ACC ] STREAM LISTENING 610686 2812/rpcbind /var/run/rpcbind.sock unix 2 [ ACC ] STREAM LISTENING 318633 4785/mysqld /var/run/mysqld/mysqld.sock Each time I modify the nginx.conf file, I make sure to relaunch this command nginx -t && nginx -s reload && echo "nginx configuration reloaded" and same thing for php5-fpm /etc/init.d/php5-fpm restart Thanks for your help :-)

    Read the article

  • F# Project Euler Problem 1

    - by MarkPearl
    Every now and then I give project Euler a quick browse. Since I have been playing with F# I have found it a great way to learn the basics of the language. Today I thought I would give problem 1 an attempt… Problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. My F# Solution I broke this problem into two functions… 1) be able to generate a collection of numbers that are multiples of a number but but are smaller than another number. let GenerateMultiplesOfXbelowY X Y = X |> Seq.unfold (fun i -> if (i<Y) then Some(i, i+X) else None) I then needed something that generated collections for multiples of 3 & 5 and then removed any duplicates. Once this was done I would need to sum these all together to get a result. I found the Seq object to be extremely useful to achieve this… let Multiples = Seq.append (GenerateMultiplesOfXbelowY 3 1000) (GenerateMultiplesOfXbelowY 5 1000) |> Seq.distinct |> Seq.fold(fun acc a -> acc + a) 0 |> Console.WriteLine |> Console.ReadLine My complete solution was … open System let GenerateMultiplesOfXbelowY X Y = X |> Seq.unfold (fun i -> if (i<Y) then Some(i, i+X) else None) let Multiples = Seq.append (GenerateMultiplesOfXbelowY 3 1000) (GenerateMultiplesOfXbelowY 5 1000) |> Seq.distinct |> Seq.fold(fun acc a -> acc + a) 0 |> Console.WriteLine |> Console.ReadLine   Which seemed to generate the correct result in a relatively short period of time although I am sure I will get some comments from the experts who know of some intrinsic method to achieve all of this in one method call.

    Read the article

  • What is up with the Joy of Clojure 2nd edition?

    - by kurofune
    Manning just released the second edition of the beloved Joy of Clojure book, and while I share that love I get the feeling that many of the examples are already outdated. In particular, in the chapter on optimization the recommended type-hinting seems not to be allowed by the compiler. I don't know if this was allowable for older versions of Clojure. For example: (defn factorial-f [^long original-x] (loop [x original-x, acc 1] (if (>= 1 x) acc (recur (dec x) (*' x acc))))) returns: clojure.lang.Compiler$CompilerException: java.lang.UnsupportedOperationException: Can't type hint a primitive local, compiling:(null:3:1) Likewise, the chapter on core.logic seems be using an old API and I have to find workarounds for each example to accommodate the recent changes. For example, I had to turn this: (logic/defrel orbits orbital body) (logic/fact orbits :mercury :sun) (logic/fact orbits :venus :sun) (logic/fact orbits :earth :sun) (logic/fact orbits :mars :sun) (logic/fact orbits :jupiter :sun) (logic/fact orbits :saturn :sun) (logic/fact orbits :uranus :sun) (logic/fact orbits :neptune :sun) (logic/run* [q] (logic/fresh [orbital body] (orbits orbital body) (logic/== q orbital))) into this, leveraging the pldb lib: (pldb/db-rel orbits orbital body) (def facts (pldb/db [orbits :mercury :sun] [orbits :venus :sun] [orbits :earth :sun] [orbits :mars :sun] [orbits :jupiter :sun] [orbits :saturn :sun] [orbits :uranus :sun] [orbits :neptune :sun])) (pldb/with-db facts (logic/run* [q] (logic/fresh [orbital body] (orbits orbital body) (logic/== q orbital)))) I am still pulling teeth to get the later examples to work. I am relatively new programming, myself, so I wonder if I am naively looking over something here, or are if these points I'm making legitimate concerns? I really want to get good at this stuff like type-hinting and core.logic, but wanna make sure I am studying up to date materials. Any illuminating facts to help clear up my confusion would be most welcome.

    Read the article

  • Automatically triggering standard spaceship controls to stop its motion

    - by Garan
    I have been working on a 2D top-down space strategy/shooting game. Right now it is only in the prototyping stage (I have gotten basic movement) but now I am trying to write a function that will stop the ship based on it's velocity. This is being written in Lua, using the Love2D engine. My code is as follows (note- object.dx is the x-velocity, object.dy is the y-velocity, object.acc is the acceleration, and object.r is the rotation in radians): function stopMoving(object, dt) local targetr = math.atan2(object.dy, object.dx) if targetr == object.r + math.pi then local currentspeed = math.sqrt(object.dx*object.dx+object.dy*object.dy) if currentspeed ~= 0 then object.dx = object.dx + object.acc*dt*math.cos(object.r) object.dy = object.dy + object.acc*dt*math.sin(object.r) end else if (targetr - object.r) >= math.pi then object.r = object.r - object.turnspeed*dt else object.r = object.r + object.turnspeed*dt end end end It is implemented in the update function as: if love.keyboard.isDown("backspace") then stopMoving(player, dt) end The problem is that when I am holding down backspace, it spins the player clockwise (though I am trying to have it go the direction that would be the most efficient at getting to the angle it would have to be) and then it never starts to accelerate the player in the direction opposite to it's velocity. What should I change in this code to get that to work? EDIT : I'm not trying to just stop the player in place, I'm trying to get it to use it's normal commands to neutralize it's existing velocity. I also changed math.atan to math.atan2, apparently it's better. I noticed no difference when running it, though.

    Read the article

  • Tail-recursive implementation of take-while

    - by Giorgio
    I am trying to write a tail-recursive implementation of the function take-while in Scheme (but this exercise can be done in another language as well). My first attempt was (define (take-while p xs) (if (or (null? xs) (not (p (car xs)))) '() (cons (car xs) (take-while p (cdr xs))))) which works correctly but is not tail-recursive. My next attempt was (define (take-while-tr p xs) (let loop ((acc '()) (ys xs)) (if (or (null? ys) (not (p (car ys)))) (reverse acc) (loop (cons (car ys) acc) (cdr ys))))) which is tail recursive but needs a call to reverse as a last step in order to return the result list in the proper order. I cannot come up with a solution that is tail-recursive, does not use reverse, only uses lists as data structure (using a functional data structure like a Haskell's sequence which allows to append elements is not an option), has complexity linear in the size of the prefix, or at least does not have quadratic complexity (thanks to delnan for pointing this out). Is there an alternative solution satisfying all the properties above? My intuition tells me that it is impossible to accumulate the prefix of a list in a tail-recursive fashion while maintaining the original order between the elements (i.e. without the need of using reverse to adjust the result) but I am not able to prove this. Note The solution using reverse satisfies conditions 1, 3, 4.

    Read the article

  • Problem running a simple EJB application

    - by Spi1988
    I am currently running a simple EJB application using a stateless Session Bean. I am working on NetBeans 6.8 with Personal Glassfish 3.0 and I have installed on my system both the Java EE and the Java SE. I don't know whether it is relevent but I am running Windows7 64-bit version. The Session Bean I implemented has just one method sayHello(); which just prints hello on the screen. When I try to run the application I'm getting the following error: pre-init: init-private: init-userdir: init-user: init-project: do-init: post-init: init-check: init: deps-jar: deps-j2ee-archive: MyEnterprise-app-client.init: MyEnterprise-ejb.init: MyEnterprise-ejb.deps-jar: MyEnterprise-ejb.compile: MyEnterprise-ejb.library-inclusion-in-manifest: MyEnterprise-ejb.dist-ear: MyEnterprise-app-client.deps-jar: MyEnterprise-app-client.compile: MyEnterprise-app-client.library-inclusion-in-manifest: MyEnterprise-app-client.dist-ear: MyEnterprise-ejb.init: MyEnterprise-ejb.deps-jar: MyEnterprise-ejb.compile: MyEnterprise-ejb.library-inclusion-in-manifest: MyEnterprise-ejb.dist-ear: pre-pre-compile: pre-compile: do-compile: post-compile: compile: pre-dist: post-dist: dist-directory-deploy: pre-run-deploy: Starting Personal GlassFish v3 Domain Personal GlassFish v3 Domain is running. Undeploying ... Initializing... Initial deploying MyEnterprise to C:\Users\Naqsam\Documents\NetBeansProjects\MyEnterprise\dist\gfdeploy\MyEnterprise Completed initial distribution of MyEnterprise post-run-deploy: run-deploy: run-display-browser: run-ac: pre-init: init-private: init-userdir: init-user: init-project: do-init: post-init: init-check: init: deps-jar: deps-j2ee-archive: MyEnterprise-app-client.init: MyEnterprise-ejb.init: MyEnterprise-ejb.deps-jar: MyEnterprise-ejb.compile: MyEnterprise-ejb.library-inclusion-in-manifest: MyEnterprise-ejb.dist-ear: MyEnterprise-app-client.deps-jar: MyEnterprise-app-client.compile: MyEnterprise-app-client.library-inclusion-in-manifest: MyEnterprise-app-client.dist-ear: MyEnterprise-ejb.init: MyEnterprise-ejb.deps-jar: MyEnterprise-ejb.compile: MyEnterprise-ejb.library-inclusion-in-manifest: MyEnterprise-ejb.dist-ear: pre-pre-compile: pre-compile: do-compile: post-compile: compile: pre-dist: post-dist: dist-directory-deploy: pre-run-deploy: Undeploying ... Initial deploying MyEnterprise to C:\Users\Naqsam\Documents\NetBeansProjects\MyEnterprise\dist\gfdeploy\MyEnterprise Completed initial distribution of MyEnterprise post-run-deploy: run-deploy: Warning: Could not find file C:\Users\Naqsam\.netbeans\6.8\GlassFish_v3\generated\xml\MyEnterprise\MyEnterpriseClient.jar to copy. Copying 1 file to C:\Users\Naqsam\Documents\NetBeansProjects\MyEnterprise\dist Copying 4 files to C:\Users\Naqsam\Documents\NetBeansProjects\MyEnterprise\dist\MyEnterpriseClient Copying 1 file to C:\Users\Naqsam\Documents\NetBeansProjects\MyEnterprise\dist\MyEnterpriseClient java.lang.NullPointerException at org.glassfish.appclient.client.acc.ACCLogger$1.run(ACCLogger.java:149) at java.security.AccessController.doPrivileged(Native Method) at org.glassfish.appclient.client.acc.ACCLogger.reviseLogger(ACCLogger.java:146) at org.glassfish.appclient.client.acc.ACCLogger.init(ACCLogger.java:93) at org.glassfish.appclient.client.acc.ACCLogger.<init>(ACCLogger.java:80) at org.glassfish.appclient.client.AppClientFacade.createBuilder(AppClientFacade.java:360) at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFacade.java:247) at org.glassfish.appclient.client.acc.agent.AppClientContainerAgent.premain(AppClientContainerAgent.java:75) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338) Java Result: 1 run-MyEnterprise-app-client: run: BUILD SUCCESSFUL (total time: 1 minute 59 seconds) see next post.

    Read the article

  • jms unresolved message-destination-ref

    - by portoalet
    hi, I am using netbeans 6.8, and glassfish v3, and making a simple jms application to work. I got this: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Unresolved Message-Destination-Ref jms/[email protected]@null into class enterpriseapplication4.Main Code: public class Main { @Resource(name = "jms/myQueue") private static Topic myQueue; @Resource(name = "jms/myFactory") private static ConnectionFactory myFactory; ... // the rest is just boiler plate created by netbeans } In my Glassfish v3 admin console, I have jms/myFactory as my ConnectionFactory and jms/myQueue as my Destination Resources. What am I missing? Full stack: WARNING: enterprise.deployment.backend.invalidDescriptorMappingFailure com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Unresolved Message-Destination-Ref jms/[email protected]@null into class enterpriseapplication4.Main at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:614) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:384) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:210) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:202) at org.glassfish.appclient.client.acc.AppClientContainer$ClientMainClassSetting.getClientMainClass(AppClientContainer.java:599) at org.glassfish.appclient.client.acc.AppClientContainer.getMainMethod(AppClientContainer.java:498) at org.glassfish.appclient.client.acc.AppClientContainer.completePreparation(AppClientContainer.java:397) at org.glassfish.appclient.client.acc.AppClientContainer.prepare(AppClientContainer.java:311) at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFacade.java:264) at org.glassfish.appclient.client.acc.agent.AppClientContainerAgent.premain(AppClientContainerAgent.java:75) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338) Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/jms/myQueue' in SerialContext targetHost=localhost,targetPort=3700 [Root exception is javax.naming.NameNotFoundException: No object bound for java:comp/env/jms/myQueue [Root exception is java.lang.NullPointerException]] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:513) ... 15 more Caused by: javax.naming.NameNotFoundException: No object bound for java:comp/env/jms/myQueue [Root exception is java.lang.NullPointerException] at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:218) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:428) ... 17 more Caused by: java.lang.NullPointerException at javax.naming.InitialContext.getURLScheme(InitialContext.java:269) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:318) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:75) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:688) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:657) at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:148) ... 18 more Regards

    Read the article

  • javascript accordian menu problem in worpress

    - by Praveen kalal
    hi all i am working on wordpress project there is i used accordion for right sidebar but all the link are over lapping each other in IE8 its working fine mozzila so plz help my code is var parentAccordion=new TINY.accordion.slider("parentAccordion"); parentAccordion.init("acc","h4",1,-1); var nestedAccordion=new TINY.accordion.slider("nestedAccordion"); nestedAccordion.init("nested","h4",1,-1,"acc-selected"); $args = array('parent'=>0,'hide_empty'=>0); $cats = get_categories($args); echo '<ul id="acc" class="acc">'; foreach($cats as $key => $val) { $args1=array( 'showposts' => 10, 'category__in' => array($val->term_id), 'caller_get_posts'=>1 ); $post=get_posts($args1); echo '<li><h4>'.$val->name.'</h4>'; echo '<div class="" style="opacity: 0; height: auto;">'; echo '<ul id="nested" class="acc">'; if(isset($post) && !empty($post)) { foreach($post as $key1 => $val1) { echo '<li class="cat-item"><a title='.$val1->post_title.' href='.$val1->guid.'>'.$val1->post_title.'</a>'; } } $subcats = get_categories(array('parent'=>$val->term_id,'hide_empty'=>0)); if(isset($subcats) && !empty($subcats)) { foreach($subcats as $k => $v) { echo '<li><h4 class="">'.$v->name.'</h4>'; $args2=array( 'showposts' => 10, 'category__in' => array($v->term_id), 'caller_get_posts'=>1 ); $post1=get_posts($args2); if(isset($post1) && !empty($post1)) { echo '<div class="" style="opacity: 1; height: auto;">'; echo '<ul class="children" style="padding-left:15px;">'; foreach($post1 as $key2 => $val2) { echo '<li><a title='.$val2->post_title.' href='.$val2->guid.'>'.$val2->post_title.'</a></li>'; } echo '</ul></div>'; } } } echo "</ul>"; echo "</li>"; } echo '</ul>'; ?> </div> so plz help me

    Read the article

  • Does JAXWS client make difference between an empty collection and a null collection value as returne

    - by snowflake
    Since JAX-WS rely on JAXB, and since I observed the code that unpack the XML bean in JAX-B Reference Implementation, I guess the difference is not made and that a JAXWS client always return an empty collection, even the webservice result was a null element: public T startPacking(BeanT bean, Accessor<BeanT, T> acc) throws AccessorException { T collection = acc.get(bean); if(collection==null) { collection = ClassFactory.create(implClass); if(!acc.isAdapted()) acc.set(bean,collection); } collection.clear(); return collection; } I agree that for best interoperability service contracts should be non ambiguous and avoid such differences, but it seems that the JAX-WS service I'm invoking (hosted on a Jboss server with Jbossws implementation) is returning as expected either null either empty collection (tested with SoapUI). I used for my test code generated by wsimport. Return element is defined as: @XmlElement(name = "return", nillable = true) protected List<String> _return; I even tested to change the Response class getReturn method from : public List<String> getReturn() { if (_return == null) { _return = new ArrayList<String>(); } return this._return; } to public List<String> getReturn() { return this._return; } but without success. Any helpful information/comment regarding this problem is welcome !

    Read the article

  • Efficiency of manually written loops vs operator overloads (C++)

    - by Sagekilla
    Hi all, in the program I'm working on I have 3-element arrays, which I use as mathematical vectors for all intents and purposes. Through the course of writing my code, I was tempted to just roll my own Vector class with simple +, -, *, /, etc overloads so I can simplify statements like: for (int i = 0; i < 3; i++) r[i] = r1[i] - r2[i]; // becomes: r = r1 - r2; Which should be more or less identical in generated code. But when it comes to more complicated things, could this really impact my performance heavily? One example that I have in my code is this: Manually written version: for (int j = 0; j < 3; j++) { p.vel[j] = p.oldVel[j] + (p.oldAcc[j] + p.acc[j]) * dt2 + (p.oldJerk[j] - p.jerk[j]) * dt12; p.pos[j] = p.oldPos[j] + (p.oldVel[j] + p.vel[j]) * dt2 + (p.oldAcc[j] - p.acc[j]) * dt12; } Using a Vector class with operator overloads: p.vel = p.oldVel + (p.oldAcc + p.acc) * dt2 + (p.oldJerk - p.jerk) * dt12; p.pos = p.oldPos + (p.oldVel + p.vel) * dt2 + (p.oldAcc - p.acc) * dt12; I am compiling my code for maximum possible speed, as it's extremely important that this code runs quickly and calculates accurately. So will me relying on my Vector's for these sorts of things really affect me? For those curious, this is part of some numerical integration code which is not trivial to run in my program. Any insight would be appreciated, as would any idioms or tricks I'm unaware of.

    Read the article

  • Having trouble with match wildcards in array

    - by Senthil
    I've a master text file and exceptions file and I want to match all the words in exception file with master file and increase counter, but the trick is with wildcards. I'm able to do without wildcards with this: words = %w(aaa aab acc ccc AAA) stop = %q(/aa./) words.each do |x| if x.match(/aa./) puts "yes for #{x}" else puts "no for #{x}" end end = yes for aaa yes for aab no for acc no for ccc yes for AAA Also which would be the best way to go about this, using arrays or some other way. Edit: Sorry for the confusion. Yes stop has multiple wildcards and I want to match all words based on those wildcards. words = %w(aaa aab acc ccc AAA) stop = %q(aa* ac* ab*) Thanks

    Read the article

  • grouping data from two dataset

    - by Garcia Julien
    hi, i've got a problem with dataset: I've got two dataset from two different server but they have the same columns. so it's like that: First DataSet : asset description make jobtype jan feb ... dec 0001 mine ik Acc 0 0 10 0002 yours ic Over 0 0 10 Second dataset : asset description make jobtype jan feb ... dec 0001 mine ik Acc 10 0 10 0002 yours ic Gen 0 0 0 But i would like to merge the 2 dataset into one like that: asset description make jobtype lhjan imjan lhfeb lhfeb ... lhdec imdec 0001 mine ik Acc 0 10 0 0 10 10 0002 yours ic Over 0 0 0 0 10 0 so all the data from one is combine with the second with the same asset and the same jobtype. I try linq but i can't arrive to make it like i want. I'm working on vb.net framework 3.5. could you help me? Julien

    Read the article

  • how to build an accumulator array in matlab

    - by schwiz
    I'm very new to matlab so sorry if this is a dumb question. I have to following matrices: im = imread('image.jpg'); %<370x366 double> [y,x] = find(im); %x & y both <1280x1 double> theta; %<370x366 double> computed from gradient of image I can currently plot points one at a time like this: plot(x(502) + 120*cos(theta(y(502),x(502))),y(502) + 120*sin(theta(y(502),x(502))),'*b'); But what I want to do is some how increment an accumulator array, something like this: acc = zeros(size(im)); acc(y,x) = acc(x + 120*cos(theta(y,x)),y + 120*sin(theta(y,x)),'*b')) + 1; It would be nice if the 120 could actually be another matrix containing different radius values as well.

    Read the article

  • Can I specify the order of how changes happen in an single App Engine transaction ? Is it equal to t

    - by indiehacker
    If I passed a list of key ids as an argument in a transaction, would the change associated with the first key in the list happen first? And if not, how do I specify the order that I want the changes to happen in? As a concrete example, consider this code below from Google Docs Transactions--would changes to the first item in acc.key() happen first? class Accumulator(db.Model): counter = db.IntegerProperty() Docshttp://code.google.com/appengine/docs/python/datastore/transactions.html: def increment_counter(key, amount): obj = db.get(key) obj.counter += amount obj.put() q = db.GqlQuery("SELECT * FROM Accumulator") acc = q.get() db.run_in_transaction(increment_counter, acc.key(), 5)

    Read the article

  • F# and ArcObjects, Part 3

    - by Marko Apfel
    Today i played a little bit with IFeature-sequences and piping data. The result was a calculator of the bounding box around all features in a feature class. Maybe a little bit dirty, but for learning was it OK. ;-) open System;; #I "C:\Program Files\ArcGIS\DotNet";; #r "ESRI.ArcGIS.System.dll";; #r "ESRI.ArcGIS.DataSourcesGDB.dll";; #r "ESRI.ArcGIS.Geodatabase.dll";; #r "ESRI.ArcGIS.Geometry.dll";; open ESRI.ArcGIS.esriSystem;; open ESRI.ArcGIS.DataSourcesGDB;; open ESRI.ArcGIS.Geodatabase;; open ESRI.ArcGIS.Geometry; let aoInitialize = new AoInitializeClass();; let status = aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcEditor);; let workspacefactory = new SdeWorkspaceFactoryClass();; let connection = "SERVER=okul;DATABASE=p;VERSION=sde.default;INSTANCE=sde:sqlserver:okul;USER=s;PASSWORD=g";; let workspace = workspacefactory.OpenFromString(connection, 0);; let featureWorkspace = (box workspace) :?> IFeatureWorkspace;; let featureClass = featureWorkspace.OpenFeatureClass("Praxair.SFG.BP_L_ROHR");; let queryFilter = new QueryFilterClass();; let featureCursor = featureClass.Search(queryFilter, true);; let featureCursorSeq (featureCursor : IFeatureCursor) = let actualFeature = ref (featureCursor.NextFeature()) seq { while (!actualFeature) <> null do yield actualFeature do actualFeature := featureCursor.NextFeature() };; let min x y = if x < y then x else y;; let max x y = if x > y then x else y;; let info s (x : IEnvelope) = printfn "%s xMin:{%f} xMax: {%f} yMin:{%f} yMax: {%f}" s x.XMin x.XMax x.YMin x.YMax;; let con (env1 : IEnvelope) (env2 : IEnvelope) = let env = (new EnvelopeClass()) :> IEnvelope env.XMin <- min env1.XMin env2.XMin env.XMax <- max env1.XMax env2.XMax env.YMin <- min env1.YMin env2.YMin env.YMax <- max env1.YMax env2.YMax info "Intermediate" env env;; let feature = featureClass.GetFeature(100);; let ext = feature.Extent;; let BoundingBox featureClassName = let featureClass = featureWorkspace.OpenFeatureClass(featureClassName) let queryFilter = new QueryFilterClass() let featureCursor = featureClass.Search(queryFilter, true) let featureCursorSeq (featureCursor : IFeatureCursor) = let actualFeature = ref (featureCursor.NextFeature()) seq { while (!actualFeature) <> null do yield actualFeature do actualFeature := featureCursor.NextFeature() } featureCursorSeq featureCursor |> Seq.map (fun feature -> (!feature).Extent) |> Seq.fold (fun (acc : IEnvelope) a -> info "Intermediate" acc (con acc a)) ext ;; let boundingBox = BoundingBox "Praxair.SFG.BP_L_ROHR";; info "Ende-Info:" boundingBox;;

    Read the article

  • LA SPÉCIALISATION POUR SE DIFFÉRENCIER ET ÊTRE VALORISÉ

    - by michaela.seika(at)oracle.com
    Software. Hardware. Complete. inside the Click Here The order you must follow to make the colored link appear in browsers. If not the default window link will appear 1. Select the word you want to use for the link 2. Select the desired color, Red, Black, etc 3. Select bold if necessary ___________________________________________________________________________________________________________________ Templates use two sizes of fonts and the sans-serif font tag for the email. All Fonts should be (Arial, Helvetica, sans-serif) tags Normal size reading body fonts should be set to the size of 2. Small font sizes should be set to 1 !!!!!!!DO NOT USE ANY OTHER SIZE FONT FOR THE EMAILS!!!!!!!! ___________________________________________________________________________________________________________________ --     LA SPÉCIALISATION  POUR SE DIFFÉRENCIER ET ÊTRE VALORISÉ       Le marché nous demande de plus en plus de solutions et d’engagements. Pour bâtir ces solutions nous nous appuyons sur vous, Partenaires Oracle. En matière d’engagements, Oracle se doit de communiquer auprès du marché quant à la spécialisation de ses partenaires, sur leurs compétences en fonction des projets que les clients nous demandent d’adresser. Plus de 50 spécialisations sont à ce jour disponibles pour les partenaires Gold, Platinum et Diamond : • Sur les produits Technologiques tels que la Base de Données, les options de la Base, la SOA, la Business Intelligence, … • Sur les produits Applicatifs, tels que l’ERP, le CRM, … • Sur les produits Hardware, les Systèmes d’exploitation. Afin de vous aider à vous spécialiser et donc à vous certifier, nos 2 distributeurs à valeur ajoutée, Altimate et Arrow ECS, vous assistent dans cette démarche. ALTIMATE vous propose de participer Lunch & Spécialisation tour Profitez de ces dispositifs qui sont mis en place pour vous afin de vous spécialiser et profiter de tous les bénéfices auxquels vous donne accès la spécialisation. ARROW ECS vous propose de participer : L'Ecole de la spécialisation Oracle by Arrow Profitez de ces dispositifs qui sont mis en place pour vous afin de vous spécialiser et profiter de tous les bénéfices auxquels vous donne accès la spécialisation. Oracle Solutions Tour Découvrez la solution Oracle lors de ce tour de France. Au programme :  roadmaps, ateliers produits et solutions, certifications     BÉNÉFICES en savoir + • l’engagement d’Oracle aux côtés des partenaires pour adresser les grands dossiers • la visibilité auprès des clients pour être identifié comme Expert sur une offre, reconnu et validé par Oracle • le support (accès support gratuit), Oracle University (vouchers pour certifier gratuitement vos équipes de Consultants Implementation) • les budgets Marketing (lead generation, création de campagnes Marketing, être sponsor d’événements clients)   Différenciez-vous en vous spécialisant sur votre domaine d’expertise et accélérez votre succès ! Oracle et ses Distributeurs à Valeur Ajoutée     Eric Fontaine Directeur Alliances & Channel Technologie Europe du Sud vous présente en vidéo la spécialisation et ses avantages.                                         CONTACTS : ORACLE Jean-Jacques PanissiéOracle Partner Development A&C Technology +33 157 60 28 52 ALTIMATE Sophie Daval +33 1 34 58 47 68 ARROW [email protected] +33 1 49 97 59 63          

    Read the article

  • problem with a join

    - by Luca Romagnoli
    I have this code: int se = (int) settings.GruppoSegreteria; var acc = db.USR_Accounts.Where( p => p.ID_Gruppo == se); var segreterie = from s in db.USR_Utenti join h in acc on s.ID equals h.USR_UtentiReference select s; And this error: The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join' I don't understand it. Can you help me? thanks

    Read the article

  • Combinations and Permutations in F#

    - by Noldorin
    I've recently written the following combinations and permutations functions for an F# project, but I'm quite aware they're far from optimised. /// Rotates a list by one place forward. let rotate lst = List.tail lst @ [List.head lst] /// Gets all rotations of a list. let getRotations lst = let rec getAll lst i = if i = 0 then [] else lst :: (getAll (rotate lst) (i - 1)) getAll lst (List.length lst) /// Gets all permutations (without repetition) of specified length from a list. let rec getPerms n lst = match n, lst with | 0, _ -> seq [[]] | _, [] -> seq [] | k, _ -> lst |> getRotations |> Seq.collect (fun r -> Seq.map ((@) [List.head r]) (getPerms (k - 1) (List.tail r))) /// Gets all permutations (with repetition) of specified length from a list. let rec getPermsWithRep n lst = match n, lst with | 0, _ -> seq [[]] | _, [] -> seq [] | k, _ -> lst |> Seq.collect (fun x -> Seq.map ((@) [x]) (getPermsWithRep (k - 1) lst)) // equivalent: | k, _ -> lst |> getRotations |> Seq.collect (fun r -> List.map ((@) [List.head r]) (getPermsWithRep (k - 1) r)) /// Gets all combinations (without repetition) of specified length from a list. let rec getCombs n lst = match n, lst with | 0, _ -> seq [[]] | _, [] -> seq [] | k, (x :: xs) -> Seq.append (Seq.map ((@) [x]) (getCombs (k - 1) xs)) (getCombs k xs) /// Gets all combinations (with repetition) of specified length from a list. let rec getCombsWithRep n lst = match n, lst with | 0, _ -> seq [[]] | _, [] -> seq [] | k, (x :: xs) -> Seq.append (Seq.map ((@) [x]) (getCombsWithRep (k - 1) lst)) (getCombsWithRep k xs) Does anyone have any suggestions for how these functions (algorithms) can be sped up? I'm particularly interested in how the permutation (with and without repetition) ones can be improved. The business involving rotations of lists doesn't look too efficient to me in retrospect. Update Here's my new implementation for the getPerms function, inspired by Tomas's answer. Unfortunately, it's not really any fast than the existing one. Suggestions? let getPerms n lst = let rec getPermsImpl acc n lst = seq { match n, lst with | k, x :: xs -> if k > 0 then for r in getRotations lst do yield! getPermsImpl (List.head r :: acc) (k - 1) (List.tail r) if k >= 0 then yield! getPermsImpl acc k [] | 0, [] -> yield acc | _, [] -> () } getPermsImpl List.empty n lst

    Read the article

  • Can my loop be optimized any more? (C++)

    - by Sagekilla
    Below is one of my inner loops that's run several thousand times, with input sizes of 20 - 1000 or more. Is there anything I can do to help squeeze any more performance out of this? I'm not looking to move this code to something like using tree codes (Barnes-Hut), but towards optimizing the actual calculations happening inside, since the same calculations occur in the Barnes-Hut algorithm. Any help is appreciated! typedef double real; struct Particle { Vector pos, vel, acc, jerk; Vector oldPos, oldVel, oldAcc, oldJerk; real mass; }; class Vector { private: real vec[3]; public: // Operators defined here }; real Gravity::interact(Particle *p, size_t numParticles) { PROFILE_FUNC(); real tau_q = 1e300; for (size_t i = 0; i < numParticles; i++) { p[i].jerk = 0; p[i].acc = 0; } for (size_t i = 0; i < numParticles; i++) { for (size_t j = i+1; j < numParticles; j++) { Vector r = p[j].pos - p[i].pos; Vector v = p[j].vel - p[i].vel; real r2 = lengthsq(r); real v2 = lengthsq(v); // Calculate inverse of |r|^3 real r3i = Constants::G * pow(r2, -1.5); // da = r / |r|^3 // dj = (v / |r|^3 - 3 * (r . v) * r / |r|^5 Vector da = r * r3i; Vector dj = (v - r * (3 * dot(r, v) / r2)) * r3i; // Calculate new acceleration and jerk p[i].acc += da * p[j].mass; p[i].jerk += dj * p[j].mass; p[j].acc -= da * p[i].mass; p[j].jerk -= dj * p[i].mass; // Collision estimation // Metric 1) tau = |r|^2 / |a(j) - a(i)| // Metric 2) tau = |r|^4 / |v|^4 real mij = p[i].mass + p[j].mass; real tau_est_q1 = r2 / (lengthsq(da) * mij * mij); real tau_est_q2 = (r2*r2) / (v2*v2); if (tau_est_q1 < tau_q) tau_q = tau_est_q1; if (tau_est_q2 < tau_q) tau_q = tau_est_q2; } } return sqrt(sqrt(tau_q)); }

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >