Say you have an array, data, of unknown length. Is there a shorter method to get elements form a starting index to the end than
subdata = data(2:length(data))
I want to have class that can be instantiated with list, array, seq, set, stack, queue etc.
In my opinion
class A
class B(elems:A*)
should handle such stuff.
This is my solution:
class A
class B(elems:Iterable[A]){
def this(elem:A) = this(Seq(elem))
}
Can you suggest any improvements?
question: how can i bind the same vector, lets say o=c(1,2,3,4) mutiple times to get a matrix like
o=array(c(1,2,3,4,1,2,3,4,1,2,3,4), dim(c(4,3))
o
[,1] [,2] [,3]
[1,] 1 1 1
[2,] 2 2 2
[3,] 3 3 3
[4,] 4 4 4
in a nicer way then: o=cbind(o,o,o) and maybe more generalized (dublicate()??
I need this to specifiy colors for elements in textplot()
thx a lot
// tmpClientList is List<Client> type
if (txtboxClientName.Text != "")
foreach (Client cli in tmpClientList)
if (cli.Name != txtboxClientName.Text)
tmpClientList.Remove(cli);
Error: "Collection was modified; enumeration operation may not execute."
How can i remove items from the list, in some simple way, without saving indexes of these items in another list or array, and removing them in another place in the code. Tried also RemoveAt(index) but it's exactly the same situation, modifying when loop runs.
Hi,
I'm using ASP.NET MVC and have a model which has an image (byte array) in one of the fields. I'm trying to output this image into the src attribute of the img tag. I'm looking to do something like '. How can I do this?
What is the proper way to remove elements from a C++ vector while iterating through it? I am iterating over an array and want to remove some elements that match a certain condition. I've been told that it's a bad thing to modify it during traversal.
Are they same ?
Came across this line when reading about Java's main method's signature
"String args[ ] declares a parameter named args, which is an array of instances of the class String. Objects of type String store character strings."
I'm implementing an MD-5 Hashing algorithm and I want to convert the text I have to bits so I can start manipulating them. As you know Hashing require taking block of bits and then manipulating them. There are many ways to do that but I can't determine the best/easiest way to just convert the text (string) into array of bits. Any clue ? In C#
Sample Data :
input : "abcdacdc"
Output : "cadb"
here we have to sort strings in order of count of characters.
If the count is same for characters. maintain the original order of
the characters from input string.
my approach: i have used array of 26 for maintaining occurrence of all characters and sort it then print it.But while doing so i am not able to maintain order in case if two characters have same count.
please suggest any improvement or any other algo.
I'm looking for a jQuery lightbox plugin that has the ability to, with it's next and previous buttons, cycle through images repeatedly. Like a carousel effect.
I've been using jQuery Lightbox Plugin (balupton edition) but that doesn't have the option to continue cycling through images. It reaches the last image in the array and then disables the 'next' button.
So to save me some time coding, what are some plugins you can recommend?
Hey,
I want to use a method of an object.
Like $myObject->helloWorld().
However there are a couple of methods so I loop through an array of method names and call the method like this:
my $methodName ="helloWorld";
$myObject->$methodNames;
This works quite nice but some objects don't have all methods.
How can I tell wether $myObject has a method called helloWorld or not?
Working on a socketbased scanner (continuous stream) using Flex for pattern recognition. Flex doesn't find a match that overlaps 'array bounderies'. So I implemented yywrap() to setup new array content as soon yylex() detects < (it will call yywrap). No success so far.
Basically (for pin-pointing my problem) this is my code:
%{
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define BUFFERSIZE 26
/* 0123456789012345678901234 */
char cbuf1[BUFFERSIZE] = "Hello everybody, lex is su"; // Warning, no '\0'
char cbuf2[BUFFERSIZE] = "per cool. Thanks! ";
char recvBuffer[BUFFERSIZE];
int packetCnt = 0;
YY_BUFFER_STATE bufferState1, bufferState2;
%}
%option nounput
%option noinput
%%
"super" { ECHO; }
. { printf( "%c", yytext[0] );}
%%
int yywrap()
{
int retval = 1;
printf(">> yywrap()\n");
if( packetCnt <= 0 ) // Stop after 2
{
// Copy cbuf2 into recvBuffer
memcpy(recvBuffer, cbuf2, BUFFERSIZE);
//
yyrestart(NULL); // ?? has no effect
// Feed new data to flex
bufferState2 = yy_scan_bytes(recvBuffer, BUFFERSIZE);
//
packetCnt++;
// Tell flex to resume scanning
retval = 0;
}
return(retval);
}
int main(void)
{
printf("Lenght: %d\n", (int)sizeof(recvBuffer)) ;
// Copy cbuf1 into recvBuffer
memcpy(recvBuffer, cbuf1, BUFFERSIZE);
//
packetCnt = 0;
//
bufferState1 = yy_scan_bytes(recvBuffer, BUFFERSIZE);
//
yylex();
yy_delete_buffer(bufferState1);
yy_delete_buffer(bufferState2);
return 0;
}
This is my output:
dkmbpro:test dkroeske$ ./text
Lenght: 26
Hello everybody, lex is su>> yywrap()
per cool. Thanks! >> yywrap()
So no match on 'super'. According to the doc the lexxer is not 'reset' between yywrap's. What do I miss? Thanks.
Hi,
Is there any inbuilt way in C# to split a text into an array of words and delimiters?
What I want is:
text = "word1 + word2 - word3";
string[] words = text.Split(new char[] { '+', '-'});
//Need list '+', '-' here?
Any ideas? Obviously I can just process the text by hand... :)
I have a few questions about CoreLocation and GPS.
First, what method in core location is used to continually get the users current coordinates? And at what interval should these be retrieved?
Second, should these coordinates be pushed into a NSMutableArray each time they are received, so that the array of coordinates will represent the users path?
Thanks, just wanting to get started getting me mind around this.
Hi,
I'm using this code now
echo $form-input('username');
How do I make sure the label shows up on a different line than the input field?
I managed to imitate what I'm trying to do, just want to make sure that I'm using it the right way.
echo $form-label('username', 'Username');
echo $form-input('username', array('label' = 'false'));
Thanks,
Tee
Hi All,
I have a string say string s ="C:\\Data" , I have an array which contains some strings containg "C:\Data" in the beginning i.e. string[] arr = new {"C:\\Data\abc.xml","C:\\Data\Test\hello.cs"};.
I have to remove the string "C:\Data" from each entry and have to combine it with another string say string fixed = "D:\\Data".
What is the best way to do it, please help as I am a new programmer in C#.
I would like to have a quick script listing all active hosts in a LAN, and I am a bit lost. From other posts I figured that this can be done most effectively by polling the DHCP server (in my case a Lancom router) using SNMP.
However, I am not familiar with the SNMP commands in PHP. Is snmpwalk() the correct function? Can I get snmpwalk() or any other php function to return an array that contains a list of all live hosts?
Hi,
I've seen in (Apple) sample code two types of ways of allocation memory, and am not sure I understand the difference and resulting behavior.
// FAILS
NSMutableArray *anArray = [NSMutableArray array];
[anArray release];
// WORKS
NSMutableArray *anArray1 = [[NSMutableArray alloc] init];
[anArray release];
By "FAILS" I mean I get crashes/runtime warnings etc., and not always as soon as I call the release...
Any explanation appreciated.
Thanks
I know normally the data is passed thru to the view with the controller. however, currently in my view I load my model ($this-load-model('Db_model');) so i can use it in a loop to retrieve a users profile picture path from a array of IDs that is passed from controller. Will loading the db model in the view to accomplish this make my site more vulnerable or bad form? To me it seems to be outside of MVC concept but its working atm. thanks
How can I find the dimensions of a matrix in Python. Len(A) returns only one variable.
Edit:
Hi Thanks.
close = dataobj.get_data(timestamps, symbols, closefield)
Is (I assume) generating a matrix of integers (less likely strings). I need to find the size of that matrix, so I can run some tests without having to iterate through all of the elements. As far as the data type goes, I assume it's an array of arrays (or list of lists).
Hi guys,
I have a database that a time filed that is stored in this format "2010.06.04. | 18:53 01".
What I need is to select rows that have a specific date, for example "2010.06.04."
Right now I am doing it my first selecting all rows and then looping through them and adding ones with the specified date to a new array.
Maybe there is an easier way to do it and I somehow can select it using mysqli_query?
Thanks!
I have a directory called "notes" within the notes I have categories which are named "science", "maths" ... within those folder are sub-categories, such as "Quantum Mechanics", "Linear Algebra".
./notes
--> ./notes/maths
------> ./notes/maths/linear_algebra
--> ./notes/physics/
------> ./notes/physics/quantum_mechanics
My problem is that I don't know how to put the categories and subcategories into TWO SEPARATE list/array.
I'm inserting a new row into my database with this code:
$data = array(
'key' => 'value'
);
$this->getDbTable()->insert($data);
How can I get the row id of the this row that I just created?
Hello all
I am having a problem using $html-link helper in my view. Consider this snippet...
/views/nodes/packages.ctp
<li><?php echo $html->link( "Package 1", array( "packages", "package1" ) )?></li>
Now when I click on the link, the address in address bar appears like
http://www.server.com/nodes/packages/packages/package1
Why is this happening? I haven't changed anything in my default routing configuration file.
Regards
Vikram
Ok, so I was comparing some stuff in my own DSL to Ruby. One construct they both support is this
x=["key" => "value"]
Knowing the difference between arrays and hashes, I would think this to be illegal, but the result in Ruby is
[{"key" => "value"}]
Why is this? And with this kinda syntax why can't you do
x=("key" => "value")
Why is an array a special case for implicitly created hashes?