Programming

Using Streamlit to Create Multiple Choice Questions (MCQ)

Written by on March 26, 2024 in Programming, Python with 0 Comments
Using Streamlit to Create Multiple Choice Questions (MCQ)

Is it possible to build a web application in Python to display (and evaluate) multiple-choice questions? Even more importantly, can we render “latex”  equations as part of the MCQ? After briefly looking at NiceGUI, Flet, Solara, Trame, and Streamlit, I decided to go ahead with Streamlit to build this web app.  Even though this was […]

Continue Reading

The Hy Programming Language – Part 2

Written by on March 9, 2024 in Hy Language, Programming with 0 Comments
The Hy Programming Language – Part 2

I wrote about “Hy” language in an earlier article. Since then I have been exploring the language some more, trying to get a better understanding of its features.  The following example uses inheritance to model different types of “Space” objects such as Asteroid, SpaceShip and Planet. It is taken from an earlier article that explained […]

Continue Reading

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

Top