In-place modification of Python lists

I found this in the docs: https://docs.python.org/3/tutorial/controlflow.html#for Python’s for statement iterates over the items of any sequence (a list or a string), in the order that they appear in the sequence. If you need to modify the sequence you are iterating over while inside the loop (for example to duplicate selected items), it is recommended … Read more

JSTL Sets and Lists – checking if item exists in a Set

You could do this using JSTL tags, but the result is not optimal: <%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core”%> <html> <body> <jsp:useBean id=”numbers” class=”java.util.HashSet” scope=”request”> <% numbers.add(“one”); numbers.add(“two”); numbers.add(“three”); %> </jsp:useBean> <c:forEach items=”${numbers}” var=”value”> <c:if test=”${value == ‘two’}”> <c:set var=”found” value=”true” scope=”request” /> </c:if> </c:forEach> ${found} </body> </html> A better way would be to use a custom … Read more

Understanding this matrix transposition function in Haskell

Let’s look at what the function does for your example input: transpose [[1,2,3],[4,5,6],[7,8,9]] <=> (map head [[1,2,3],[4,5,6],[7,8,9]]) : (transpose (map tail [[1,2,3],[4,5,6],[7,8,9]])) <=> [1,4,7] : (transpose [[2,3],[5,6],[8,9]]) <=> [1,4,7] : (map head [[2,3],[5,6],[8,9]]) : (transpose (map tail [[2,3],[5,6],[8,9]])) <=> [1,4,7] : [2,5,8] : (transpose [[3],[6],[9]]) <=> [1,4,7] : [2,5,8] : (map head [[3],[6],[9]]) : (transpose … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)