|
Agreed with the Python recommendation. All of the scientific Python software I've written has used scipy, which is a superset of numpy. numpy is basically your vector math library (and it gives you the detailed datatype control you need); on top of that scipy provides a ton of algorithms that work with those vectors (FFTs, Simplex methods, linear regressions, all kinds of statistics, etc.), as well as matplotlib (a fairly capable plotting library), and a few other things I never had reason to work extensively with.
|
# ? Apr 27, 2016 20:59 |
|
|
# ? May 30, 2024 20:42 |
|
Der Shovel posted:
Couldn't you just iterate over your lists, and use a map function that spits out the original name or the TERROR DETECTED version, depending on whether the name is found in your watchlist? e- like this, since I'm not on my phone now code:
code:
baka kaba fucked around with this message at 17:32 on Apr 28, 2016 |
# ? Apr 28, 2016 14:16 |
|
Walh Hara posted:It's probably possible to simplify this a lot by using monads, but I don't know which one to use and didn't want to bother writing one myself. Thanks, this is actually helpful. I'll look into it Right now I'm having the stupidest problem, though. I'm trying to write files. I have a list of Strings, which I want to write into a text file. If I just have one String I want to write, that's easy enough and code:
Here's what I've tried: code:
Googling does not really help me here.
|
# ? Apr 28, 2016 18:21 |
|
You can use "sequence" to run a list of IO () (that is, to go [IO a] -> IO [a]):code:
|
# ? Apr 28, 2016 19:00 |
|
God damnit, I should've remembered that. Thanks EDIT: Good GOD this is slow! I mean I'm not surprised it's slow, since I'm doing discrete IO operations while writing a massive .txt file one line at a time. Is there a better way of doing all the writing at once through newlines or something? For the record, I did a simple program that accepts as its input a .txt file with columns of census data, strips away all but the first column, makes sure everything is written with proper cases and then outputs the results into a separate file. It works fine but JESUS this output is taking forever. Possibly because the source file is three megs E2: Welp, that was easy enough! code:
Shaman Tank Spec fucked around with this message at 20:19 on Apr 28, 2016 |
# ? Apr 28, 2016 19:57 |
|
Even more succinct:code:
mapM_ discards the results of the operation, which are just a list of empty tuples in this case. If you want the results for some reason (can't imagine why) you can use the regular mapM.
|
# ? Apr 28, 2016 19:59 |
|
LOOK I AM A TURTLE posted:To write Haskell code is to forever search for a way to reduce your entire program to a single library function call that does all the stuff you just spent the last hour working out. My main problem with Haskell is that reading code from other people is often really difficult as you keep have to look up what some weird library function does. In any code that's not trivially simply I also often end up wondering whether a certain function is defined somewhere else in the code or is from a library. I stopped programming in Haskell when I encountered this function in somebody else's code: https://hackage.haskell.org/package/base-4.8.2.0/docs/Control-Arrow.html#v:second It's probably a really easy concept once you understand it, but I just found it incredible frustrating that I kept having to spend so much time researching weird library functions.
|
# ? Apr 28, 2016 20:19 |
Just checking in to say I've starting my migration to a python-based approach and enjoying it so far. Matlab will remain in my toolbox, but having explicit dictionaries, etc alongside numpy's tools is really nice. Thanks again!
|
|
# ? Apr 28, 2016 21:50 |
|
Hi, I was looking for some information about programming and this thread seems like a good resource. I have a few questions I think would help me prepare for a new gig I've landed. I'm a Digital Project Manager with an emphasis on managing what I assume will be the implementation, and/or maintenance, of a site that offers services such as the refinancing of vehicles and applying for auto loans. Since I only have less than a year of experience managing these types of projects I'm hoping you guys could give me some tips or things to consider to refresh my general knowledge. Here are some questions I have: -What are the most common types of CMSs used for sites that offer these services, or for newly built/updated sites with similar purposes? -In regards to those CMSs/sites, what are some of pointers I need to be aware of? (i.e. most common maintenance issues, compatibility with other types of software/programming languages, potential security risks) -Are there any references (preferably free) I could seek out that pertain to programming for sites and apps? Like a beginner's level intro that explains the basic principles of web and mobile development (I see on the first page you guys mentioned The Practice of Programming and Code Complete so this may already be answered). Any help would be much appreciated.
|
# ? Apr 29, 2016 17:24 |
|
Can anybody give me some direction on getting two PCs to communicate via USB? Or at the least one end needs to be USB. Needs to be a Linux and C++ solution (working with an existing simulator but it only runs on the same machine using a virtual usb solution). Been looking at USB OTG and USB networking among other things but I'm not familiar with USB so I'm just kind of shooting in the dark.
|
# ? Apr 29, 2016 18:29 |
|
Mr. Crow posted:Can anybody give me some direction on getting two PCs to communicate via USB? Or at the least one end needs to be USB. Needs to be a Linux and C++ solution (working with an existing simulator but it only runs on the same machine using a virtual usb solution). You'll need to use a 'bridge cable' AFAIK because USB works on the host/target model, not like a serial cable does between two computers. In fact you'll cross power lines or something and could damage the ports. They used to sell data transfer kits back in the Windows 98/XP days that came with a special cable and special software to do the transfer.
|
# ? Apr 29, 2016 19:30 |
|
Bob Morales posted:You'll need to use a 'bridge cable' AFAIK because USB works on the host/target model, not like a serial cable does between two computers. In fact you'll cross power lines or something and could damage the ports. Right, but I'm having trouble finding anything that doesn't have some propriety software attached to it making it useless for my purposes. If you or anyone else know of a cable with an API that would be great?
|
# ? Apr 29, 2016 19:34 |
|
Mr. Crow posted:Right, but I'm having trouble finding anything that doesn't have some propriety software attached to it making it useless for my purposes. Honestly I'm curious what you simulator 'device' side looks like if not that.
|
# ? Apr 29, 2016 19:36 |
Mr. Crow posted:Right, but I'm having trouble finding anything that doesn't have some propriety software attached to it making it useless for my purposes. Your best bet is an USB Ethernet adapter, I'd say.
|
|
# ? Apr 29, 2016 19:36 |
|
JawnV6 posted:Would you be comfortable with a COM port on both ends? http://www.ftdichip.com/Products/Cables/USBtoUSB.htm This might work, I'll need to look into it. Basically on one machine we have app communicating with some device with USB and/or serial connection. For testing the app somebody wrote a simulator, my job was to throw it into a docker container and provide it to the testing department. Unfortunately I guess the serial communication was to slow and it doesn't really behave like the actual device, so they created a virtual USB solution (because of my current problem) but it has to run on the same machine, which was acceptable at the time for developer testing but now it needs to work without modifying the host machine at all, so here I am.
|
# ? Apr 29, 2016 19:50 |
I think Linux also has a "USB Gadget" driver which allows you to configure the system as a USB device rather than host, but I don't really know anything about it other than that it exists. It probably requires special hardware; I don't think normal host controllers can be reprogrammed to act as targets instead.
|
|
# ? Apr 29, 2016 20:14 |
|
The virtual USB device was using that but it didn't appear to be on my Ubuntu VM, the app is on a in-house spin of Ubuntu so I thought it was some proprietary thing, didn't look into it. But the null modem cable solution should work so cheers.
|
# ? Apr 30, 2016 00:34 |
|
I'm doing some research on unit testing, and I'm seeing a lot of people talking about how good TDD is. Is it universally accepted as the way to go, or is it another one of the things that people argue over, like most things I ask about? While I'm asking, I'm working on a game mod. I'm not sure if it's how patched together the engine was from 2001-2010, or if it's the other mods included in the code I'm building off of, but it's taking about an hour to compile. Are there any guides on reducing compile time on a big project like that? Or is it a matter of optimizing each file and project one at a time? 22 Eargesplitten fucked around with this message at 03:17 on May 2, 2016 |
# ? May 2, 2016 03:14 |
|
22 Eargesplitten posted:I'm doing some research on unit testing, and I'm seeing a lot of people talking about how good TDD is. Is it universally accepted as the way to go, or is it another one of the things that people argue over, like most things I ask about? It's one of those things people argue about. It definitely can help make your development more rigorous (not to mention help ensure that you have unit tests), but it requires a certain mentality of development where you can know that the tests and the spec and what is actually needed are all in agreement. Which can be hard to achieve in many software shops.
|
# ? May 2, 2016 03:39 |
|
22 Eargesplitten posted:While I'm asking, I'm working on a game mod. I'm not sure if it's how patched together the engine was from 2001-2010, or if it's the other mods included in the code I'm building off of, but it's taking about an hour to compile. Are there any guides on reducing compile time on a big project like that? Or is it a matter of optimizing each file and project one at a time? If your toolchain has some way of doing precompiled headers (it should), definitely use them. (I'm assuming this is C++; I don't know what else would take that long to compile.)
|
# ? May 2, 2016 04:42 |
|
TDD is a great way to get better at writing code that can actually be unit tested, so purely for educational purposes I believe everyone should spend a while doing it. It is not the best way to solve every single problem you will ever encounter. I personally only actually follow TDD when I'm writing something with a clearly defined "correct" result but I have no idea on how to even get started on producing that result.
|
# ? May 2, 2016 05:04 |
|
My Haskell trials continue. I'm still working on parsing text and replacing parts of it with other text. The problem I'm wrestling with right now is this: 1. Find out if substring X appears as part of String Y. 2. If it does, pass it on to another list so I can later replace it with another String. Now, on its surface this is extremely simple and can be achieved with something like a simple list comprehension. For instance: code:
code:
E: I'm not married to list comprehensions here, but I find I'm constantly hitting my head against conventions and practises I learned from OOP and which might not work that well for Haskell. My original plan was to write functions which would do a more thorough job of checking against various edge cases but they became horribly unwieldy and monstrous. Shaman Tank Spec fucked around with this message at 14:52 on May 2, 2016 |
# ? May 2, 2016 14:40 |
|
It seems like you want to do more than what is listed in your requirements. Lets split the problem up: 1. We have an input list of strings :: [String] 2. We have a predicate to filter these strings on :: String -> Bool -- (this would be your isInfixOf or whatever) Look at 'filter' to do this bit, no list comprehension required. 3. For all strings that pass the filter, you want to retrieve a certain substring. You have a function f :: String -> String to do this Use 'map' to apply this function to your strings. It isn't quite clear from your post what the function in 3. does: code:
|
# ? May 2, 2016 15:04 |
|
s1: John Smith's s2: Nothing So basically I want any suffixes, like possessives, plurals etc. And yeah, I was originally messing around with trying to combine filter and map, but I guess I couldn't figure out the precise syntax needed to combine flip, map and filter E: basically here's the whole thing. 1. We have an arbitrary String of text. I was originally planning on splitting this text into smaller Strings through splitOn("\n") but decided against it since it doesn't really do me much good. 2. We have lists of smaller Strings that might be names, objects or places. 3. I want to run checks to see if any names, objects or places from my lists of Strings appear in the long Strings, and if they do, add them to new lists for later post-processing. This would be easy as heck if my smaller Strings were single words or if I could be sure that they didn't have possessive suffixes, weren't pluralized etc, but that would be too limiting. Here's a sample of what I'm trying to do: code:
Shaman Tank Spec fucked around with this message at 16:03 on May 2, 2016 |
# ? May 2, 2016 15:51 |
|
Der Shovel posted:1. We have an arbitrary String of text. I was originally planning on splitting this text into smaller Strings through splitOn("\n") but decided against it since it doesn't really do me much good. Depending on your dictionary and input size, brute forcing it by doing regex searches over the entire string for each dictionary item may be entirely feasible.
|
# ? May 2, 2016 16:12 |
|
baquerd posted:Depending on your dictionary and input size, brute forcing it by doing regex searches over the entire string for each dictionary item may be entirely feasible. I know of regex but don't really have any experience with it. E: and honestly I'd prefer to learn the "proper" way of doing it with Haskell, since I figure one of the cases where Haskell might actually be useful for me is for making tools like this. Shaman Tank Spec fucked around with this message at 16:35 on May 2, 2016 |
# ? May 2, 2016 16:20 |
|
raminasi posted:If your toolchain has some way of doing precompiled headers (it should), definitely use them. (I'm assuming this is C++; I don't know what else would take that long to compile.) Thanks. Yeah, it's C++. I'm using VS2013, so it looks like it should work. e: Well, there are 27 .pch files already. But there are also 6462 .h files 22 Eargesplitten fucked around with this message at 17:31 on May 2, 2016 |
# ? May 2, 2016 17:16 |
|
/\s(John Smith\S*)/ is all you need, it's a very simple regex problem. Choosing the right tool isn't a sign of weakness.
|
# ? May 2, 2016 17:24 |
|
Der Shovel posted:I know of regex but don't really have any experience with it. If you have a set of substrings that you're checking for in larger strings then regex would be an incredibly easy and fast way of doing so. That being said, if you don't know all the possible substrings ahead of time, or the specific construction of the larger strings (ie: where substrings might appear, common elements that are always, or are often in place) then I don't know how much use it would be.
|
# ? May 2, 2016 20:13 |
|
Regexes are an incredibly powerful tool for string manipulation, searching, and extraction. They are consequently the "correct" way to do pretty much anything more complicated than "is this substring in this string", "take the first/last N characters of this string", and "split this string into tokens based on this delimiter". It's worth your time to learn to use regexes, just like it's worth your time to learn to use databases, write functional code, write unit tests, etc. Even if they aren't a tool you use often, knowing that they're available and being able to recognize what they can do can/will save you a ton of time.
|
# ? May 2, 2016 20:22 |
|
JawKnee posted:That being said, if you don't know all the possible substrings ahead of time, or the specific construction of the larger strings (ie: where substrings might appear, common elements that are always, or are often in place) then I don't know how much use it would be. That's part of the problem, I don't know that. I can probably hack together a solution that'll get me 95% of the way there and will just not work for edge cases like plurals and possessives. I've been thinking about this on and off all evening long, and I'm wondering if it wouldn't be better to make custom functions for every possible type.
|
# ? May 2, 2016 20:28 |
|
I know I know the answer to this, but I'm drawing a huge blank. What's the name of this pattern?code:
|
# ? May 2, 2016 20:40 |
|
That's just functions as first-class objects (or "first-class functions"). I guess using that specifically for an object constructor is like having an extremely bare-bones factory.
|
# ? May 2, 2016 20:43 |
|
OK, Haskell and -- possibly -- folds. Let's say I want to apply a function, in this case replace (replace oldValue newValue where_to_replace), several times to the same String with different values for oldValue and newValue, I'd use a fold, right? Because if I used map, I wouldn't end up making n changes to my target string, I'd end up with n instances of my target string each with one change made to it, right? But is even a fold the right thing to use here, or should I try to make some kind of recursive function that is run n times on the same material, manually iterating through my lists of values?
|
# ? May 2, 2016 21:44 |
Yes if you have a list of (oldValue,newValue) tuples, and a single string, and you want to use the tuples as replacements in the string, folding would be a way of doing it.
|
|
# ? May 2, 2016 21:57 |
|
foldl is almost always implemented recursively. (foldr sometimes gets weird)
|
# ? May 3, 2016 07:20 |
|
Mr. Crow posted:Can anybody give me some direction on getting two PCs to communicate via USB? Or at the least one end needs to be USB. Needs to be a Linux and C++ solution (working with an existing simulator but it only runs on the same machine using a virtual usb solution). You could always get USB-> Serial and then join the 2 with a serial crossover cable or how about USB-> Ethernet and put a small hub in the middle
|
# ? May 3, 2016 07:26 |
|
TooMuchAbstraction posted:Regexes are an incredibly powerful tool for string manipulation, searching, and extraction. They are consequently the "correct" way to do pretty much anything more complicated than "is this substring in this string", "take the first/last N characters of this string", and "split this string into tokens based on this delimiter". Well, to a point. Insert 'how do I parse HTML with regexes' zalgo page here.
|
# ? May 3, 2016 14:44 |
|
Here's a small question. Does Haskell offer any kind of syntactic sugar for this type of situation: code:
|
# ? May 3, 2016 14:45 |
|
|
# ? May 30, 2024 20:42 |
|
code:
|
# ? May 3, 2016 14:59 |