Search Results

Search found 1806 results on 73 pages for 'lazy evaluation'.

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

  • NHibernate FetchMode.Lazy

    - by RyanFetz
    I have an object which has a property on it that has then has collections which i would like to not load in a couple situations. 98% of the time i want those collections fetched but in the one instance i do not. Here is the code I have... Why does it not set the fetch mode on the properties collections? [DataContract(Name = "ThemingJob", Namespace = "")] [Serializable] public class ThemingJob : ServiceJob { [DataMember] public virtual Query Query { get; set; } [DataMember] public string Results { get; set; } } [DataContract(Name = "Query", Namespace = "")] [Serializable] public class Query : LookupEntity<Query>, DAC.US.Search.Models.IQueryEntity { [DataMember] public string QueryResult { get; set; } private IList<Asset> _Assets = new List<Asset>(); [IgnoreDataMember] [System.Xml.Serialization.XmlIgnore] public IList<Asset> Assets { get { return _Assets; } set { _Assets = value; } } private IList<Theme> _Themes = new List<Theme>(); [IgnoreDataMember] [System.Xml.Serialization.XmlIgnore] public IList<Theme> Themes { get { return _Themes; } set { _Themes = value; } } private IList<Affinity> _Affinity = new List<Affinity>(); [IgnoreDataMember] [System.Xml.Serialization.XmlIgnore] public IList<Affinity> Affinity { get { return _Affinity; } set { _Affinity = value; } } private IList<Word> _Words = new List<Word>(); [IgnoreDataMember] [System.Xml.Serialization.XmlIgnore] public IList<Word> Words { get { return _Words; } set { _Words = value; } } } using (global::NHibernate.ISession session = NHibernateApplication.GetCurrentSession()) { global::NHibernate.ICriteria criteria = session.CreateCriteria(typeof(ThemingJob)); global::NHibernate.ICriteria countCriteria = session.CreateCriteria(typeof(ThemingJob)); criteria.AddOrder(global::NHibernate.Criterion.Order.Desc("Id")); var qc = criteria.CreateCriteria("Query"); qc.SetFetchMode("Assets", global::NHibernate.FetchMode.Lazy); qc.SetFetchMode("Themes", global::NHibernate.FetchMode.Lazy); qc.SetFetchMode("Affinity", global::NHibernate.FetchMode.Lazy); qc.SetFetchMode("Words", global::NHibernate.FetchMode.Lazy); pageIndex = Convert.ToInt32(pageIndex) - 1; // convert to 0 based paging index criteria.SetMaxResults(pageSize); criteria.SetFirstResult(pageIndex * pageSize); countCriteria.SetProjection(global::NHibernate.Criterion.Projections.RowCount()); int totalRecords = (int)countCriteria.List()[0]; return criteria.List<ThemingJob>().ToPagedList<ThemingJob>(pageIndex, pageSize, totalRecords); }

    Read the article

  • Why Stream/lazy val implementation using is faster than ListBuffer one

    - by anrizal
    I coded the following implementation of lazy sieve algorithms using Stream and lazy val below : def primes(): Stream[Int] = { lazy val ps = 2 #:: sieve(3) def sieve(p: Int): Stream[Int] = { p #:: sieve( Stream.from(p + 2, 2). find(i=> ps.takeWhile(j => j * j <= i). forall(i % _ > 0)).get) } ps } and the following implementation using (mutable) ListBuffer: import scala.collection.mutable.ListBuffer def primes(): Stream[Int] = { def sieve(p: Int, ps: ListBuffer[Int]): Stream[Int] = { p #:: { val nextprime = Stream.from(p + 2, 2). find(i=> ps.takeWhile(j => j * j <= i). forall(i % _ > 0)).get sieve(nextprime, ps += nextprime) } } sieve(3, ListBuffer(3))} When I did primes().takeWhile(_ < 1000000).size , the first implementation is 3 times faster than the second one. What's the explanation for this ? I edited the second version: it should have been sieve(3, ListBuffer(3)) instead of sieve(3, ListBuffer()) .

    Read the article

  • Strange lazy load problem

    - by JooLio
    public class QuickQuoteTemplate { ... public virtual IList<QuickQuoteTemplateItem> InnerItems { get; set; } ... } public class QuickQuoteTemplateItem { ... public virtual IList<QuickQuoteTemplateItem> InnerItems { get; set; } ... } <class name="QuickQuoteTemplate" table="SA_QUICK_QUOTE_TEMPLATE"> ... <bag name="InnerItems" lazy="false" inverse="true" cascade="delete" > <key column="PARENT_QQ_TEMPLATE_ID" ></key> <one-to-many class="QuickQuoteTemplateItem" /> </bag> ... </class> <class name="QuickQuoteTemplateItem" table="SA_QUICK_QUOTE_TEMPLATE_ITEMS"> ... <bag name="InnerItems" lazy="false" inverse="false" cascade="delete"> <key column="PARENT_ITEM_ID" /> <one-to-many class="QuickQuoteTemplateItem" /> </bag> ... </class> InnerItems collections is set as no lazy, but after disposing the ISession instance, quickQuote.InnerItems is crying "failed to lazily initialize a collection, no session or session was closed". I've even tried to call InnerItems before the session is closed by myself. It successfully retrieves, but after disposing of the session it becomes not initialized.

    Read the article

  • Delayed evaluation in Clojure

    - by StackedCrooked
    I'm having some trouble understanding how the delay macro works in Clojure. It doesn't seem to do what expect it to do (that is: delaying evaluation). As you can see in this code sample: ; returns the current time (defn get-timestamp [] (.getTime (java.util.Date.))) ; var should contain the current timestamp after calling "force" (def current-time (delay (get-timestamp))) However, calling current-time in the REPL appears to immediately evaluate the expression, even without having used the force macro: user=> current-time #<Delay@19b5217: 1276376485859> user=> (force current-time) 1276376485859 Why was the evaluation of get-timestamp not delayed until the first force call?

    Read the article

  • Avoiding NPE in trait initialization without using lazy vals

    - by 0__
    This is probably covered by the blog entry by Jesse Eichar—still I can't figure out how to correct the following without residing to lazy vals so that the NPE is fixed: Given trait FooLike { def foo: String } case class Foo( foo: String ) extends FooLike trait Sys { type D <: FooLike def bar: D } trait Confluent extends Sys { type D = Foo } trait Mixin extends Sys { val global = bar.foo } First attempt: class System1 extends Mixin with Confluent { val bar = Foo( "npe" ) } new System1 // boom!! Second attempt, changing mixin order class System2 extends Confluent with Mixin { val bar = Foo( "npe" ) } new System2 // boom!! Now I use both bar and global very heavily, and therefore I don't want to pay a lazy-val tax just because Scala (2.9.2) doesn't get the initialisation right. What to do?

    Read the article

  • NHibernate WCF Bidirectional and Lazy loading

    - by ChrisKolenko
    Hi everyone, I'm just looking for some direction when it comes to NHibernate and WCF. At the moment i have a many to one association between a person and address. The first problem. I have to eager load the list of addresses so it doesn't generate a lazy loaded proxy. Is there a way to disable lazy loading completely? I never want to see it generated. The second problem. The bidirectional association between my poco's is killing my standard serialization. What's the best way forward. Should I remove the Thanks for all your help

    Read the article

  • Linux USB debug connection to LuminaryMicro evaluation board

    - by mikelong
    Hi, I am trying to connect a Stellaris LM3S8962 evaluation kit to a linux host machine. I am using the CodeSourcery G++ for the development toolchain. When I try to run a helloworld example the connection fails with this message: arm-stellaris-eabi-sprite: error: E104. I/O Error communicating with USB Device. arm-stellaris-eabi-sprite: waiting for GDB connection, to pass error along warning: Remote failure reply: E.fatal.E104. I/O Error communicating with USB Device. arm-stellaris-eabi-sprite: error: E002. Not initialized When I connect the evaluation board with the USB cable it seems the device is made available to the system: Mar 24 14:37:16 n6-ws2 kernel: usb 5-2: USB disconnect, address 5 Mar 24 14:37:18 n6-ws2 kernel: usb 5-2: new full speed USB device using uhci_hcd and address 6 Mar 24 14:37:19 n6-ws2 kernel: usb 5-2: configuration #1 chosen from 1 choice Also, it seems that I can connect in some way via the command line tool (but I do get some strange characters): [mlong@n6-ws2 bin]$ ./arm-stellaris-eabi-sprite -i CodeSourcery ARM Debug Sprite (Sourcery G++ 4.4-104) armusb: [speed=] ARMUSB device armusb:///?? - ?? (??) Does anyone have any suggestions I could try? Thanks a lot, Mike

    Read the article

  • What is the best way to evaluate new programmers?

    - by Rafael
    What is the best way to evaluate the best candidates to get a new job (talking merely in terms of programming skills)? In my company we have had a lot of bad experiences with people who have good grades but do not have real programming skills. Their skills are merely like code monkeys, without the ability to analyze the problems and find solutions. More things that I have to note: The education system in my country sucks--really sucks. The people that are good in this kind of job are good because they have talent for it or really try to learn on their own. The university / graduate /post-grad degree doesn't mean necessarily that you know exactly how to do the things. Certifications also mean nothing here because the people in charge of the certification course also don't have skills (or are in low paying jobs). We need really to get the good candidates that are flexible and don't have mechanical thinking (because this type of people by experience have a low performance). We are in a government institution and the people that are candidates don't necessarily come from outside, but we have the possibility to accept or not any candidates until we find the correct one. I hope I'm not sounding too aggressive in my question; and BTW I'm a programmer myself. edit: I figured out that asked something really complex here. I will un-toggle "the correct answer" only to let the discussion going fluent, without any bias.

    Read the article

  • Evolution of an Application: how to manage and improve core engine?

    - by Phil Carter
    The web application I work on has been live for a year now, but it's time for it to evolve and one of the ways in which it is evolving is into a multi-brand application - in this case several different companies using the application, different templates/content and some slight business logic changes between them. The problem I'm facing is implementing a best practice across the site where there are differences in business logic for each brand. These will mostly be very superficial, using a an alternative mailing list provider or capturing some extra data in a form. I don't want to have if(brand === x) { ... } else { ... } all over the site especially as most of what needs to be changed can be handled with extending the existing class. I've thought of several methods that could be used to instantiate the correct class, but I'm just not sure which is going to be best especially as some seem to lead to duplication of more code than should be necessary. Here's what I've considered: 1) Use a Static Loader similar to Zend_Loader which can take the class being requested, and has knowledge of the Brand and can then return the correct object. $class = App_Loader::getObject('User', $brand); 2) Factory classes. We use these in the application already for Products but we could utilise them here also to provide a transparent interface to the class. 3) Routing the page request to a specific brand controller. This however seems like it would duplicate a lot of code/logic. Is there a pattern or something else I should be considering to solve this problem? 4) How to manage a growing project that has multiple custom instances in production? Update This is a PHP application so the decisions on which class to load are made per request. There could be upwards of 100+ different 'brands' running.

    Read the article

  • How do managers know if a person is a good or a bad programmer?

    - by Pavel Shved
    In most companies that do programming teams and divisions consist of programmers who design and write code and managers who... well, do the management stuff. Aside from just not writing code, managers usually do not even look at the code the team develops, and may even have no proper IDE installed on their work machines. Still, the managers are to judge if a person works well, if he or she should be put in charge of something, or if particular developer should be assigned to a task of the most importance and responsibility. And last, but not least: the managers usually assign the quarterly bonuses! To do the above effectively, a manager should know if a person is a good programmer—among other traits, of course. The question is, how do they do it? They don't even look at the code people write, they can't directly assess the quality of the components programmers develop... but their estimates of who is a good coder, and who is "not as good" are nevertheless correct in most cases! What is the secret?

    Read the article

  • Would Using a PHP Framework Be Beneficial in My Context?

    - by Fractal
    I've just started work at a small start-up company who mainly uses PHP to develop their front-end apps. I had no prior PHP experience before joining, and this has led to my apps becoming large pieces of spaghetti code. I essentially started by adding code to implement an initial feature, and then continued to hack in more code to implement further features – without much thought for the overall design. The apps themselves output XML to render on small mobile devices. I recently started looking into frameworks that I could use. I reckon an advantage would be that they seem to force developers to modularise their programs using good-practice design patterns. This seems great for someone in my position. The extra functions they provide, for example: interfacing with databases in such a way as to make SQL injection impossible, would be very useful too. The downside I can see is that there will be a lot of overhead for me in terms of the time taken to learn the framework itself (while still getting to grips with PHP itself). I'm also worried that it will be overkill for the scale of the apps we develop. They tend to be programs that interface with a fairly simple back-end DB, and will generate about 5 different XML screens. Probably around 1 or 2 thousand lines of code. The time it takes just to configure the frameworks may not be worth it. The final problem I can see is that developers in the company – who have to go over my code, and who do not know the PHP framework I may use – will have a much harder time understanding it. Given those pros and cons, I'm still not sure on what the best course of action will be; so any advice will be greatly appreciated.

    Read the article

  • How to manage and improve web application with 50 customers?

    - by Muhammet Göktürk Ayan
    First of all, sorry for my English. We've developed a Web Application using ASP.NET and Sql Server. We've started selling it and of course are still continually improving and developing it. The question is, how do we go about updating each client's version of the site? We have, maybe, 50 customers. 50 different folders and 50 different db's sounds like a bad idea. Is there any known method for solving this kind of scenario? For Explain: We are developing a Crm, for 50 companies. They will have 10 users maybe. It makes 500 users and their customers and products.

    Read the article

  • Why does this static field always get initialized over-eagerly?

    - by TheSilverBullet
    I am looking at this excellent article from Jon Skeet. While executing the demo code, Jon Skeet says that we can expect three different kinds of behaviours. To quote that article: The runtime could decide to run the type initializer on loading the assembly to start with... Or perhaps it will run it when the static method is first run... Or even wait until the field is first accessed... When I try this out (on framework 4), I always get the first result. That is, the static method is initialized before the assembly is loaded. I have tried running this multiple times and get the same result. (I tried both the debug and release versions) Why is this so? Am I missing something?

    Read the article

  • C#4: Why does this static field always get initialized over-eagerly?

    - by TheSilverBullet
    I am looking at this excellent article from Jon Skeet at this location: http://csharpindepth.com/Articles/General/Beforefieldinit.aspx While executing the demo code, Jon Skeet says that we can expect three different kinds of behaviours. To quote that article: The runtime could decide to run the type initializer on loading the assembly to start with... Or perhaps it will run it when the static method is first run... Or even wait until the field is first accessed... When I try this out (on framework 4), I always get the first result. That is, the static method is initialized before the assembly is loaded. I have tried running this multiple times and get the same result. (I tried both the debug and release versions) Why is this so? Am I missing something?

    Read the article

  • How do you price your work?

    - by Dr.Kameleon
    Well, let me explain : This has really been an issue for me, for such a long time. And what is worse - since coding is something I simply ADORE (I would definitely do it, even if there was no payment involved whatsoever..) - is that I always end up feeling somewhat awkward... Anyway... So, here's the deal : You start working on a project, you may have something in your mind, and even if you're lucky enough and the client needs no "cost estimates" beforehand, sooner or later you'll face the ultimate dilemma of pricing your own work. So, how do YOU do it? By estimating the time you put into it? (obviously, this is not exact, 'coz perhaps a more capable coder will need much less time for the very same thing than a not-so-competent coder + even the very same coder may not "perform" equally at all times) By the Lines of code you've written? (obviously, this is not a measure either : a 10-line script that does exactly the same with a 1000-line script is, at least for me, "better") By taking into account the level of complexity of the project and, perhaps, how specialised the subject is? By taking into account other factors? (e.g. the value of the project for your customer)

    Read the article

  • How is fundamental mathematics efficiently evaluated by programming languages?

    - by Korvin Szanto
    As I get more and more involved with the theory behind programming, I find myself fascinated and dumbfounded by seemingly simple things.. I realize that my understanding of the majority of fundamental processes is justified through circular logic Q: How does this work? A: Because it does! I hate this realization! I love knowledge, and on top of that I love learning, which leads me to my question (albeit it's a broad one). Question: How are fundamental mathematical operators assessed with programming languages? How have current methods been improved? Example var = 5 * 5; My interpretation: $num1 = 5; $num2 = 5; $num3 = 0; while ($num2 > 0) { $num3 = $num3 + $num1; $num2 = $num2 - 1; } echo $num3; This seems to be highly inefficient. With Higher factors, this method is very slow while the standard built in method is instantanious. How would you simulate multiplication without iterating addition? var = 5 / 5; How is this even done? I can't think of a way to literally split it 5 into 5 equal parts. var = 5 ^ 5; Iterations of iterations of addition? My interpretation: $base = 5; $mod = 5; $num1 = $base; while ($mod > 1) { $num2 = 5; $num3 = 0; while ($num2 > 0) { $num3 = $num3 + $num1; $num2 = $num2 - 1; } $num1 = $num3; $mod -=1; } echo $num3; Again, this is EXTREMELY inefficient, yet I can't think of another way to do this. This same question extends to all mathematical related functions that are handled automagically.

    Read the article

  • Writing better timesheet

    - by gunbuster363
    Recently, my company started to require us to fill out a monthly timesheet, writing down everything you do in office. A timesheet contain 29-31 days, depends on the number of days of the month. I need to write the things I did in every row of the excel file, which represent a day. This timesheet embarrasses me, because something like this can happen: I spent Monday writing a program, and the program was done. Because my boss didn't give me other program to write, basically I am just sitting there and pretending I am busy in the following days before my boss gives me another assignment. Of course I should not write it in the timesheet as it is. I can write it in the timesheet that I write the program using 4 days, but it makes me feel very inefficient. I can separate the process into 1) write the program, 2)deploy the program, 3)test the program, but that can make the process so long like 3 weeks, really. Have you encountered such a situation? How would you deal with this? EDIT: some people said I should be more proactive about asking for more assignments, but here is the situation: the boss of my boss gives some jobs to my boss, then my boss gives the jobs to me, sometimes I can also see my boss being quite less busy. One of my colleagues said that I should not ask for another assignment in a proactive manner, because it would be a headache for my boss to think a job out of nowhere for me. I don't want the things turn out like that, really.

    Read the article

  • EJB3 Entity and Lazy Problem

    - by Stefano
    My Entity beAN have 2 list: @Entity @Table(name = "TABLE_INTERNAL") public class Internal implements java.io.Serializable { ...SOME GETTERS AND SETTERS... private List<Match> matchs; private List<Regional> regionals; } mapped one FetchType.LAZY and one FetchType.EAGER : @OneToMany(fetch = FetchType.LAZY,mappedBy = "internal") public List<Match> getMatchs() { return matchs; } public void setMatchs(List<Match> matchs) { this.matchs = matchs; } @ManyToMany(targetEntity = Regional.class, mappedBy = "internals", fetch =FetchType.EAGER) public List<Regional> getRegionals() { return regionals; } public void setRegionals(List<Regional> regionals) { this.regionals = regionals; } I need both lists full ! But I cant put two FetchType.EAGER beacuse it's an error. I try some test: List<Internal> out; out= em.createQuery("from Internal").getResultList(); out= em.createQuery("from Internal i JOIN FETCH i.regionals ").getResultList(); I'm not able to fill both lists...Help!!! Stefano

    Read the article

  • Lazy non-modifiable list in Google Collections

    - by mindas
    I was looking for a decent implementation of a generic lazy non-modifiable list implementation to wrap my search result entries. The unmodifiable part of the task is easy as it can be achieved by Collections.unmodifiableList() so I only need to sort out the the lazy part. Surprisingly, google-collections doesn't have anything to offer; while LazyList from Apache Commons Collections does not support generics. I have found an attempt to build something on top of google-collections but it seems to be incomplete (e.g. does not support size()), outdated (does not compile with 1.0 final) and requiring some external classes, but could be used as a good starting point to build my own class. Is anybody aware of any good implementation of a LazyList? If not, which option do you think is better: write my own implementation, based on google-collections ForwardingList, similar to what Peter Maas did; write my own wrapper around Commons Collections LazyList (the wrapper would only add generics so I don't have to cast everywhere but only in the wrapper itself); just write something on top of java.util.AbstractList; Any other suggestions are welcome.

    Read the article

  • Help me understand entity framework 4 caching for lazy loading

    - by Chris
    I am getting some unexpected behaviour with entity framework 4.0 and I am hoping someone can help me understand this. I am using the northwind database for the purposes of this question. I am also using the default code generator (not poco or self tracking). I am expecting that anytime I query the context for the framework to only make a round trip if I have not already fetched those objects. I do get this behaviour if I turn off lazy loading. Currently in my application I am breifly turning on lazy loading and then turning it back off so I can get the desired behaviour. That pretty much sucks, so please help. Here is a good code example that can demonstrate my problem. Public Sub ManyRoundTrips() context.ContextOptions.LazyLoadingEnabled = True Dim employees As List(Of Employee) = context.Employees.Execute(System.Data.Objects.MergeOption.AppendOnly).ToList() 'makes unnessesary round trip to the database, I just loaded the employees' MessageBox.Show(context.Employees.Where(Function(x) x.EmployeeID < 10).ToList().Count) context.Orders.Execute(System.Data.Objects.MergeOption.AppendOnly) For Each emp As Employee In employees 'makes unnessesary trip to database every time despite orders being pre loaded.' Dim i As Integer = emp.Orders.Count Next End Sub Public Sub OneRoundTrip() context.ContextOptions.LazyLoadingEnabled = True Dim employees As List(Of Employee) = context.Employees.Include("Orders").Execute(System.Data.Objects.MergeOption.AppendOnly).ToList() MessageBox.Show(employees.Where(Function(x) x.EmployeeID < 10).ToList().Count) For Each emp As Employee In employees Dim i As Integer = emp.Orders.Count Next End Sub Why is the first block of code making unnessesary round trips?

    Read the article

  • Lazy non-modifiable list

    - by mindas
    I was looking for a decent implementation of a generic lazy non-modifiable list implementation to wrap my search result entries. The unmodifiable part of the task is easy as it can be achieved by Collections.unmodifiableList() so I only need to sort out the the lazy part. Surprisingly, google-collections doesn't have anything to offer; while LazyList from Apache Commons Collections does not support generics. I have found an attempt to build something on top of google-collections but it seems to be incomplete (e.g. does not support size()), outdated (does not compile with 1.0 final) and requiring some external classes, but could be used as a good starting point to build my own class. Is anybody aware of any good implementation of a LazyList? If not, which option do you think is better: write my own implementation, based on google-collections ForwardingList, similar to what Peter Maas did; write my own wrapper around Commons Collections LazyList (the wrapper would only add generics so I don't have to cast everywhere but only in the wrapper itself); just write something on top of java.util.AbstractList; Any other suggestions are welcome.

    Read the article

  • Model class for NSDictionary information with Lazy Loading

    - by samfu_1
    My application utilizes approx. 50+ .plists that are used as NSDictionaries. Several of my view controllers need access to the properties of the dictionaries, so instead of writing duplicate code to retrieve the .plist, convert the values to a dictionary, etc, each time I need the info, I thought a model class to hold the data and supply information would be appropriate. The application isn't very large, but it does handle a good deal of data. I'm not as skilled in writing model classes that conform to the MVC paradigm, and I'm looking for some strategies for this implementation that also supports lazy loading.. This model class should serve to supply data to any view controller that needs it and perform operations on the data (such as adding entries to dictionaries) when requested by the controller functions currently planned: returning the count on any dictionary adding one or more dictionaries together Currently, I have this method for supporting the count lookup for any dictionary. Would this be an example of lazy loading? -(NSInteger)countForDictionary: (NSString *)nameOfDictionary { NSBundle *bundle = [NSBundle mainBundle]; NSString *plistPath = [bundle pathForResource: nameOfDictionary ofType: @"plist"]; //load plist into dictionary NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile: plistPath]; NSInteger count = [dictionary count] [dictionary release]; [return count] }

    Read the article

  • Stop lazy-loading images?

    - by Greg
    Here's the issue – I followed along with the Apple lazy-load image sample code to handle my graphical tables. It works great. However, my lazy-load image tables are being stacked within a navigation controller so that you can move in and out of menus. While all this works, I'm getting a persistent crash when I move into a table then move immediately back out of it using the "back" button. This appears to be a result of the network connections loading content not being closed properly, or calling back to their released delegates. Now, I've tried working through this and carefully setting all delegates to nil and calling close on all open network connections before releasing a menu. However, I'm still getting the error. Also – short posting my entire application code into this post, I can't really post a specific code snippet that illustrates this situation. I wonder if anyone has ideas for tasks that I may be missing? Do I need to do anything to close a network connection other than closing it and setting it to nil? Also, I'm new to debugging tools – can anyone suggest a good tool to use to watch network connections and see what's causing them to fail? Thanks!

    Read the article

  • breadth-first traversal of directory tree is not lazy

    - by user855443
    I try to traverse the diretory tree. A naive depth-first traversal seems not to produce the data in a lazy fashion and runs out of memory. I next tried a breadth first approach, which shows the same problem - it uses all the memory available and then crashes. the code i have is: getFilePathBreadtFirst :: FilePath -> IO [FilePath] getFilePathBreadtFirst fp = do fileinfo <- getInfo fp res :: [FilePath] <- if isReadableDirectory fileinfo then do children <- getChildren fp lower <- mapM getFilePathBreadtFirst children return (children ++ concat lower) return (children ++ concat () else return [fp] -- should only return the files? return res getChildren :: FilePath -> IO [FilePath] getChildren path = do names <- getUsefulContents path let namesfull = map (path </>) names return namesfull testBF fn = do -- crashes for /home/frank, does not go to swap fps <- getFilePathBreadtFirst fn putStrLn $ unlines fps I think all the code is either linear or tail recursive, and I would expect that the listing of filenames starts immediately, but in fact it does not. Where is the error in my code and my thinking? where have I lost lazy evaluation?

    Read the article

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