Skip to main content

Posts

Drive Bot In A Path

#define LEFT 13 #define RIGHT 12 #define PATH_DURATION1 5000 #define PATH_DURATION2 1000 #define PATH_DURATION3 500 // the setup function runs once when you press reset or power the board void setup() {   // initialize digital pin LED_BUILTIN as an output.   pinMode(LEFT, OUTPUT);    pinMode(RIGHT, OUTPUT); } // the loop function runs over and over again forever void loop() {   moveStraight();   delay(PATH_DURATION1);          moveRight();   delay(PATH_DURATION2);        moveStraight();   delay(PATH_DURATION1);   moveLeft();   delay(PATH_DURATION2); } void moveStraight(){   digitalWrite(LEFT, HIGH);   digitalWrite(RIGHT,HIGH);           // turn the LED on (HIGH is the voltage level) } void moveRight(){   digitalWrite(LEFT,HIGH);   digitalWrite(RIGHT,LOW); } void moveLeft(){   digitalWrite(LEFT,LOW);  ...

Learning C from Snippets : Pointers to structures

struct exam{ int a; char *ch; }st[]={10,"Testing",11,"Computer",12,"Science",13,"Engineering",14,"Custo",15,"2018"}; int main() { struct exam *e = st; printf("%s, ",e++->ch); ++e; printf("%s, ",++e->ch);   // -> operator has higher precedence than the ++ opearator. printf("%s, ",++e++->ch); printf("%d, ",e[0].a); printf("%s",++e->ch); return 0; } OUTPUT : Testing, cience, ience, 13, ngineering

Learning C from Snippets : What does pointer +1 means ?

int main(int argc, char** argv) { char p[3][4]={{'R','B','R','a'},{'S','R','K','a'},{'A','P','J','a'}}; printf("%d\n",p); //Prints 7339584 printf("%d",p+1); //Prints 7339588 , i.e there is an addition of 4 to the previous number return 0; } int main(int argc, char** argv) { char p[3][3]={{'R','B','R'},{'S','R','K'},{'A','P','J'}}; printf("%d\n",p); //Prints 7339584 printf("%d",p+1);//Prints 7339583 return 0; } _________________________________________________________________________________ int main(int argc, char** argv) { char p[3][2]={{'R','A'},{'S','R'},{'A','P'}}; printf("%c",*(p+1)); //Prints B return 0; } int main(int argc, char** argv) { char p[3][3]={{'R','B','R...

Ensemble Learning

In ensemble learning we combine the output of multiple classifiers in order to on better prediction on classification accuracy. The classifcation of resultant classifer is better then the resultant classifier. We need a way to combine the output of multiple classifiers. First we generate a group of base learners. These learners will be using different algorithms.(say learner which uses a Dicision Tree,Neural Network, Support Vector Machine etc..), they could be same algorithms with different hyperparameters, could have different representations or may use different training sets. Muliple learner will give different classifications. 

Uniqueness of Scala

* The declared type of a symbol is given after the symbol and a colon. The declared type can often be omitted, because the compiler can infer it from the context. * A mixin is a class that provides certain functionality to be inherited by a subclass and isn’t meant for instantiation by itself. A mixin could also be viewed as an interface with implemented methods. * Array types are written Array[T] rather than T[], and array selections are written a(i) rather than a[i]. * Functions can be nested inside other functions. Nested functions can access parameters and local variables of enclosing functions. For instance, the name of the array xs is visible in functions swap and sort1, and therefore need not be passed as a parameter to them.

Why Scala

1. Type Inference : Uses type inference to allow the compiler to infer the type of variables from the instances bound to them. We would write the equivalent line in Scala as follows: val myInstance = new Example() The Scala compiler infers that myInstance has the Example type at compile time. A lot of the time, it is enough to specify the types of the arguments and of the return value of a function. The compiler can then infer types for all the variables defined in the body of the function. Scala code is usually much more concise and readable than the equivalent Java code, without compromising any of the type safety. 2. Immutable objects : Scala encourages the use of immutable objects. val rollnos = List("720", "729") // List is immutable rollnos(1) = "5" // Compile-time error Knowing that some objects cannot be changed once instantiated reduces the number of places bugs can creep in. 3.Functional Programming : Scala encourages functio...

GoLang from Programming Template

About Memory: 1. How do I get memory, i.e how are variables declared. Any specific facts and constrains about variables ? Basic data types are here .Declare the variables which you'll need outside the entry point of main function. Something like : var ( ToBe   bool       = false MaxInt uint64     = 1<<64 - 1 z      complex128 = cmplx.Sqrt(-5 + 12i) ) local variables can be declared as shown as example in explanation of FOR loop. 2. How do we get the entry point for the program execution ? [ Example : main() in the C program ] func main() --> is the entry point of the program execution. 3. How does dynamic memory handled ? Is it supported in first place ? Yes dynamic memory is supported.  new  allocates zeroed storage for a new item or type whatever and then returns a pointer to it. Go has garbage collection. This means the Go runtime checks in the background if an object or any other varia...