We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Function

C++ : How to Sort a List of objects with custom Comparator or lambda function

In this example we will discuss different ways to sort a std::list of user defined data types with custom comparators or lambda functions. Suppose we have a type Player that contains Id and name. Advertisements struct Player { int id; std::string name; Player(int playerId, std::string playerName) : id(playerId), name(playerName) { } bool operator <(const Player …

C++ : How to Sort a List of objects with custom Comparator or lambda functionRead More

C++11 Lambda : How to capture member variables inside Lambda function

In this article we will discuss how to capture member variables from outer scope. Suppose we have a class OddCounter to keep the track of odd numbers read by the object. Inside its member function we are creating a lambda function and passing to a STL algorithm std::for_each. Advertisements Now this lambda function needs to capture …

C++11 Lambda : How to capture member variables inside Lambda functionRead More

Unary Operator Overloading in C++ using both member & Friend function

In this article we will discuss how to overload unary operators in c++ using both member and Friend function. What is an unary operator? An Unary operator is an operator that operates on a single operand and returns a new value. Advertisements Some of the unary operators are, ++ (Increment Operator) —   (Decrement operator) –    (Unary …

Unary Operator Overloading in C++ using both member & Friend functionRead More

Python: How to sort a list of tuples by 2nd Item using Lambda Function or Comparator

In this article we will discuss how to sort a list of tuple using 2nd or i th item of tuple. Suppose we have a list of tuple i.e. words and thier frequency count, Advertisements # List of tuples i.e. word and its frequency count wordFreq = [ (‘the’ , 34) , (‘at’ , 23), …

Python: How to sort a list of tuples by 2nd Item using Lambda Function or ComparatorRead More

Python : *args | How to pass multiple arguments to function ?

In this article we will discuss how to define a function in python that can accept variable length arguments. Suppose we have a function to calculate the average of 3 numbers i.e. Advertisements def average(a , b, c): ”’ Function To calculate the average of 3 numbers ”’ return (a+b+c)/3 Now let’s use this function, …

Python : *args | How to pass multiple arguments to function ?Read More

Python : How to unpack list, tuple or dictionary to Function arguments using * & **

In this article we will discuss how to unpack a list, tuple and dictionary to function arguments. Suppose we have a function with 3 parameters i.e. Advertisements def updateStudentDetail(name, phone, address): print(“**********************”) print(“Student Name : “, name) print(“Student phone : “, phone) print(“Student address : “, address) We can call this function and pass three …

Python : How to unpack list, tuple or dictionary to Function arguments using * & **Read More

pandas.apply(): Apply a function to each row/column in Dataframe

In this article we will discuss how to apply a given lambda function or user defined function or numpy function to each row or column in a dataframe. Python’s Pandas Library provides an member function in Dataframe class to apply a function along the axis of the Dataframe i.e. along each row or column i.e. …

pandas.apply(): Apply a function to each row/column in DataframeRead More

Python : How to Create a Thread to run a function in parallel ?

In this article we will discuss how to create threads in python that will run a function (with or without arguments) in parallel to main thread. Python provides a threading module to manage threads. To use that we need to import this module i.e. Advertisements import threading Now Python’s threading module provides a Thread class …

Python : How to Create a Thread to run a function in parallel ?Read More

Cart

Your Cart is Empty

Back To Shop