Programming :: Haskell - I/O Not In Order?
Apr 18, 2011
I'm learning Haskell from an on-line tutorial, and trying to figure out how I/O works. I'm a bit confused with this example:
Code:
My expectation is for it to ask me for a line, then for it to convert the line I provide to uppercase (err... create a new line that is uppercase) and then output said line.
However, what actually happens when I run it is it firsts ask me for a line, then outputs "Next line: ", then outputs the uppercase line:
Code:
I realize that Haskell is not an imperative language, but I was (mistakenly?) under the impression that there was some kind of sequence guaranteed in the do blocks. Could someone explain why this happens, and how I can "fix" my code to get the desired behavior?
I'm running:
- Linux version 2.6.34-gentoo-r12 (64-bit)
- GNU bash, version 4.1.9(2)-release (x86_64-pc-linux-gnu)
- Glasgow Haskell Compiler, Version 6.12.3, for Haskell 98, stage 2 booted by GHC version 6.12.3
View 2 Replies
ADVERTISEMENT
Aug 25, 2010
how to use socket programming in order to implement chatting feature
View 5 Replies
View Related
Jul 26, 2011
I want to change the parameter for ThreadLimit for one file as shown below using sed. I want to ignore the commented line. But the command I am using also executing with commented line.
# ThreadLimit: maximum setting of ThreadsPerChild
ThreadLimit 25
I want the desired output as
# ThreadLimit: maximum setting of ThreadsPerChild
#ThreadLimit 25
ThreadLimit 50
For this I am using command.
sed '/ThreadLimit/{;h;s/^/#/p;x;s/ .*/ 50/;}' test.txt.1 > test.txt
View 7 Replies
View Related
Jun 9, 2010
Say I have a text file with10 columns. I need to reorder them based on a list of column numbers that will reorder them.
My problem is this:
If I want to cut out 5 columns (columns 1,2,3,9,10) in the order 1,10,2,9,3 then I have tried using:
Code: cut -f1,10,2,9,3 my_file.txt > reordered_file.txt But this just extracts the columns in order as if I used:
Code: cut -f1,2,3,9,10 my_file.txt > reordered_file.txt How can I cut these columns and place them into the new file in the order I specify?
While this might seem quite trivial, I will actually need to do this for a file containing ~14000 columns with ~12000 columns that I need to extract in a particular order.
View 2 Replies
View Related
Apr 27, 2009
Here is what I have so far.The program receives and echos characters without syscalls. I am trying to add 2 procedures(rev7 and putint)Rev7: Reverses the least significant 7 bits and outputs $s2Putint: Prints the decimal value of $s2.When i run it, it echos the character then prints a "P". I have no idea where that comes from.Everything seems correct to me but I do not understand why it does not print the decimal digits
Code:
.data
hello:.asciiz "Enjoy This Program
[code]....
View 2 Replies
View Related
Apr 21, 2010
I would like to know if is it necessary(and why) to use setsid to create a session leader in order to create a daemon process?
View 1 Replies
View Related
Apr 19, 2010
I'm writing a PHP script, and I need a top 10 result from a mysql query.I've tryed like this:select IP,sum(download) from traf group by IP order by ASC limit 0,10and my sql returnsmysql> select IP,sum(download) from traf group by IP order by ASC limit 0, 10;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC limit 0, 10' at line 1As I red through Google this is not quite supported by mysql, so is there another way to do this?
View 5 Replies
View Related
Jun 16, 2011
I wonder if it is possible to avoid JNI in order to port a c/c++ STL application to android ?Do I have an alternative for calling C/C++ (STL) code ?
View 2 Replies
View Related
Aug 12, 2010
I'm trying to write an extension to PHP which means coding in C. I'm really really rusty at C coding and was never very good at it.
Can anyone propose an efficient, safe, and [hopefully] future-proof way of reversing a double? Keep in mind that it should work on as many systems as possible and on 32- and 64-bit systems (and on ???-bit systems in the future?). Will the size of a 'double' ever change or will it always be 8 bytes?
I've tried this and it doesn't work...the compiler complains about "invalid operands to binary" because I'm trying bitwise shiftw on a non-integer.
Code:
x = (x>>56) |
((x<<40) & 0x00FF000000000000) |
((x<<24) & 0x0000FF0000000000) |
((x<<8) & 0x000000FF00000000) |
[Code]....
View 3 Replies
View Related
Feb 24, 2010
When I parse a XML file, should I rely on the order of elements?
For example say we have:
Should I rely on the above order?
Would the following still be valid:
I'm trying to find out if a well formed XML document should have an ordered structure, or if it's still valid XML if it has no order.
View 7 Replies
View Related
Aug 18, 2010
in my text file of 5 columns 2 column is in DDMMYYYY format. (ie DATE OF BIRTH). how to use sort command for its ascending order and descending order.
Is the same can be use for the date format YYYYMMDD ?
View 3 Replies
View Related
Mar 12, 2010
I'd like to create a script which allows me to order its data (let's say: Name, age, department and work start date) by date. And display the result in another file.
View 1 Replies
View Related
Mar 21, 2011
Examples:
Code:
$ ./test.sh -a -c 2
operator is -gt
remcount is
^ value missing!
Code:
$ ./test.sh -b -c 2
operator is -lt
remcount is
^ value missing!
Yet when "-c" is the first argument, its value is present:
Code:
$ ./test.sh -c 2 -b
operator is -lt
remcount is 2
What could I do to ensure the value of "-c" is picked up regardless of the argument order?
View 5 Replies
View Related
Nov 22, 2010
How do I install Haskell (ghc) for opensuse 11.3?It is on the build service here:but only for openSUSE_11.3 not openSUSE_Factory.openSUSE_11.3 contains a lot of RPMs do I need to download and install all of them?It would be easier if I cold install from YAST but I have tried searching for Haskell or ghc in both software management and package search (webpin) and neither combination returns any results. This thread suggests that it did work in 11.2:Install Haskell for 11.2 from build.opensuse.orgI have the default repositories installed (oss and non-oss) I have not removed any repositories
View 4 Replies
View Related
May 12, 2011
Probably a stupid sounding question, but bear with me please. I need to use the link grammar parser in order to do some part of speech tagging. It's freely available and works once you run the makefile or 'make' it or however it's correctly said. Thing is, it has a C API which I intend to use. And once I ran a bit of the sample code given in the documentation it gave a whole host of errors. This is very confusing because I'm including the path for the folder that has all the header files.
gcc -I/path/include/ filename.c. But it still gives me errors about not being able to find things that are clearly defined there. An hour of trudging around the internet tells me I need to 'compile' the API first. I'm not exactly sure how or if I'm supposed to do that. If someone could just shed light on this it would be greatly appreciated. I grow increasingly cynical to the musical swell of my tiny brain rattling in my skull.
View 5 Replies
View Related
Dec 7, 2010
I've a program which manages my pdf and references. I wish to put some of the information on my website but that program (Mendeley) does export only in XML (or bibtex). I'd like to simply convert the XML output files to SQL in order to create or update an SQL database.I'm not an expert in either XML or SQL (use only PHPMyadmin). Does someone get help me to figure out?
View 2 Replies
View Related
Oct 21, 2010
I am trying to write a bash script that will extract a .cbr (.rar) file, traverse the extracted files in alphabetical order and rename them 001.JPG, 002.JPG, 003.JPG, etc.So far I only have this much to extract it:
Code:
#!/bin/bash
#
[code]....
View 8 Replies
View Related
May 1, 2011
I have made two source files named as sum.c and average.cI have included sum.c in average.c
both files in Documents directory.when i compile average.ot followingerror"average.c:4:22: fatal error: sum.c: No such file or directorycompilation terminated.How to solve this issue?I have tried to copy sum.c to usrinclude folder but unable to copy
View 8 Replies
View Related
Jul 24, 2010
I'm trying to add local sockets in my multi-threaded application in order to exchange data between threads. The only problem I got is that most of the information available on the net is related to internet oriented socket programming whileI want to perform local connections. got a thread that does the sniffing via libpcap. And I would like that thread to send each captured packet to a second thread that will analyse the packetof the thread implementations is written in separate .h file.Or maybe there is a more effective method of exchanging data between threads
View 14 Replies
View Related
Feb 21, 2010
how can i manipulate the source code of ps command in order to hide a process from the list that run by ps.as you know ps command list all the process that exist in /proc.so how can i do this??this is part of my assingment...
View 13 Replies
View Related
Feb 2, 2010
How would I list 4 users ID numbered 10, 11, 12 and 13 from my users list and output them to a file busers where their names are numbered by ascending order? How would I accomplish that on a one line command?
View 4 Replies
View Related
Jan 10, 2010
I have recieved CD in the past and I don't have a functional DVD burner to create my own disk. It says I cantribute to the Ubuntu community for more CDs but there isn't a way for me to get one. What should I do about this? I mean I'm on the forums but IDK how to tell shipit about my activity
View 2 Replies
View Related
May 22, 2010
I am a new Ubuntu user in Hungary, where we use reverse name orders (perhaps called the "eastern name order"). I mean Hasselhoff David instead of David Hasselhoff. Its quite a big problem for me, especially during syncing with my phone (which finally works now, after a few days of reading and searching...).Is it possible to change that in Ubuntu?
View 5 Replies
View Related
Nov 25, 2010
Back in the days of Archimedes I was able to move a window with the middle mouse button and it kept the z-order. Now I've jumped to Linux from a long time with Windows I'm hoping this is possible again! Its very useful when trying to see 2 windows together without changing focus. Ideally, I'd change the Alt+Winow drag behaviour to keep the z-order.
View 1 Replies
View Related
May 5, 2010
How can i set the order of controllers which Debian loads? One of my problems is that it is initializing my PCI-e controllers first and my OS drive is being named /dev/sde. Also is it possible to list which port of which controller a HDD is plugged into?
Code:
:~# lspci
00:00.0 Host bridge: ATI Technologies Inc RX780/RX790 Chipset Host Bridge
00:04.0 PCI bridge: ATI Technologies Inc RD790 PCI to PCI bridge (PCI express gpp port A)
00:06.0 PCI bridge: ATI Technologies Inc RD790 PCI to PCI bridge (PCI express gpp port C)
00:0a.0 PCI bridge: ATI Technologies Inc RD790 PCI to PCI bridge (PCI express gpp port F)
00:11.0 SATA controller: ATI Technologies Inc SB700/SB800 SATA Controller [AHCI mode]
[Code].....
View 1 Replies
View Related
Jun 22, 2010
I am trying to write a script to set the SGE job execution order. I named each job with 'job1', 'job2' and 'job3'. I want my script to do: When 'job1' execution is complete, 'job2' is executed; when both 'job1' and 'job2' are complete, 'job3' is executed.
First, I tried this following script and it worked well:
########
qsub -N job1 run1.sh # run1.sh includes "mv file_name1 file_name2"
qsub -N job2 -hold_jid job1 run2.sh # run2.sh includes "mv file_name2
file_name3"
########
[Code]....
View 7 Replies
View Related
Jun 16, 2011
how slow XP was on my laptop, a casual friend (who moved away and I have since lost touch with) installed Fed 11 as a dual boot with XP, Fed 11 first. It has worked great for email and some net surfing. Now the machine is going to my wife, who does not want have to go to the boot menu to get XP. How do I change the order so that XP boots first and you have to go to the menu to get Fed 11? I've tried going through the forums, but since I'm not really a computer person, there are some basics I don't know (for example "open a terminal" - how does one do that?)
View 5 Replies
View Related
Apr 27, 2010
I worte somewhere in time here about this, but I cant find it.. I have a problem, when starting KDE, it begins to start applications, usually the ones that were open (thanks God)... however, order is a bit screwed... It opens Skype, KTorrent, Kopete, Sound, Keyboard and finally, NetworkManager...I would like to put Network to be ran 1st.
View 9 Replies
View Related
Mar 30, 2010
The mentioned repository seems to be out of order. Does anybody knows something about? New user X
View 9 Replies
View Related
Feb 7, 2010
Does the order of command options matter?
View 4 Replies
View Related