Programming

Generating Polynomials – Part 2

Written by on December 10, 2023 in LISP, Programming with 0 Comments
Generating Polynomials – Part 2

In my last article, I showed how we can use Prolog to generate univariate Polynomials. After I finished that article, I wanted to try Lisp for the same task. Prolog is “declarative”, whereas Lisp is primarily “functional” (it supports OOP as well), so the implementation will exhibit that difference. Here is the primary function generate-polynomial […]

Continue Reading

Generating Polynomials in Prolog

Written by on November 26, 2023 in Programming, Prolog with 0 Comments
Generating Polynomials in Prolog

Polynomial is an important topic in High School maths curriculum. There are many online courses that explain the topic in great details with lots of examples and sample exercises. Wouldn’t it be interesting if we can generate polynomials of given degree programmatically? It turns out that this is not such a hard problem after all. […]

Continue Reading

C++20: “constinit” Specifier

Written by on October 15, 2023 in C++, Programming with 0 Comments
C++20: “constinit” Specifier

The constinit specifier, introduced in C++20, is applied to static variables (global and local static) and thread local variables, with the requirement that they either have a zero initialization or they are initialized with a compile-time constant expression. Here is our first example: Line 17 declares a global constinit variable, initialized with a constant value. […]

Continue Reading

C++23: if consteval

Written by on September 24, 2023 in C++, Programming with 0 Comments
C++23: if consteval

“If consteval” is useful in the context of calling a consteval function from within a constexpr function. A consteval function can only be invoked in a constant expression and hence is evaluated at compile-time. On the other hand, a constexpr function may be invoked in a constant expression or non-constant expression. If invoked in a […]

Continue Reading

Simulating Python Zip in Lisp

Written by on September 4, 2023 in LISP, Programming, Python with 1 Comment
Simulating Python Zip in Lisp

The zip() function in Python is a convenient mechanism for iterating over multiple “iterables” in parallel. Looping over lists is a common scenario. Here is the output generated by the above code: Common Lisp does not have such a feature built into the language or as part of the standard library. Of course, we have […]

Continue Reading

std::is_scoped_enum<>

Written by on August 13, 2023 in C++, Programming with 0 Comments
std::is_scoped_enum<>

The type trait “std::is_scoped_enum<T>::value” was introduced in C++23 to check whether the type “T” is a scoped enum type. Another way to use this is std::is_scoped_enum_v<T>. Before getting into this trait in detail, let us briefly recap the differences between unscoped and scoped enums. Unscoped Enums Unscoped enums are the old-style enums. Look at the […]

Continue Reading

The “===” Operator in Julia

Written by on July 23, 2023 in Julia, Programming with 0 Comments
The “===” Operator in Julia

In addition to the conventional “==” operator that checks if two objects are equal, Julia has the “===” operator to check for equality. What is the difference between these two operators? The “==” operator checks whether two objects have the same value. Here are some examples: Cell 5 shows that the RHS float value is […]

Continue Reading

The Sum Type in V Programming Language

Written by on July 2, 2023 in Programming, Vlang with 0 Comments
The Sum Type in V Programming Language

A Sum data type in V language gives us a convenient way to hold objects of many distinct types (at any time, just one object) and hence is a discriminated union. For example, in C++ we have the variant type. Here is an example of sum type in V language: In the above program, the […]

Continue Reading

C++23: “stacktrace” Library

Written by on June 6, 2023 in C++, Programming with 0 Comments
C++23: “stacktrace” Library

The ability to enumerate stack frames at runtime is one of the interesting features introduced in C++23. This is made possible through the <stacktrace> header. The interface is quite simple. Here is a piece of code showing how to use the library. There are 4 functions and here is the call chain: The “dumpStackTrace()” function […]

Continue Reading

std::expected<>

Written by on May 13, 2023 in C++, Programming with 0 Comments
std::expected<>

I had written about std::optional<> in an earlier article. C++23 introduces std::expected<> as an interesting extension to std::optional<>. Whereas std::optional<> contains a value or none at all, std::expected<> contains a value or an error code associated with it. This gives better control to the caller in terms of handling the outcome of the function call. […]

Continue Reading

Top