Clojure allows you to test for equality using the equals(=) sign.
;you can compare two things
(= 1 1) ;true
;you can compare multiple things
(= 1 1 1) ;true
;if any of them are not equal then we get false
(= 1 1 2) ;false
;if something is not strictly equal then we get false
(= 2 2.0) ;false
;but we can also check for loose equality (Notice two equals)
(== 2 2.0) ;true
;and it's not just numbers that can be compared
(= "abc" (str "a" "b" "c")) ;true
It’s been a while since I wrote on this blog. Been busy in many things. Recently I decided to start learning Clojure. I thought the best way to keep at it would be to start writing about it. So I decided that I am going to start writing posts every now and then about anything I learn in Clojure. Inspired by Groovy Goodness I’ll try to work on “Clojure-snips”. Hopefully I will improve with time as I learn Clojure. I’ll keep a list of posts here.
I had mentioned last month that I am working on a bookmarker. Yeah I am still working and it is progressing. The search page is ready. I am using a work-around for adding the bookmarks and categories till the bookmark add page is ready. But I am happy with the work so far as it is becoming what I wanted although a bit slower due to lack of time. Here are some screenshots of working search page.
The search box has an autocomplete for giving suggestions for categories. It will give suggestions as per added categories. Pressing up down keys lets you navigate the categories and when you press enter the category is added on the page alongwith all bookmarks.
Below are some screenshots.
There is currently not much bookmarks added so only two categories came in autocomplete for search and one bookmark was added when category was chosen.
I forgot to mention earlier that the little cross in red lets you delete the category and the bookmarks tagged with the category. Obviously needed.
Making Graphical User Interface(GUI) can be really attractive to many people. I had also been really interested in making GUIs and after using Visual Studio Express briefly for a project I could not forget the ease with which it allowed someone to make GUIs. So in Python I was interested in making GUIs. I had looked at many choices starting with Tkinter the default Python GUI toolkit. Believe me you don’t want to use it as it does not have a decent WSIWYG editor for building the GUIs. After failing to get anything from TkInter I looked at wxPython but it supported Python 2 only and last time I checked it’s Python 3 support was a Work-In-Progress.
PySide and PyQt looked promising as PyQt Designer is a decent WYSIWYG editors but PyQt needs a commercial license and PySide is kinda dead – community support and tutorials.
Kivy is said to be cross-platform and it has a good tutorial – official documentation has a tutorial for making a game and it has a WIP editor also. I think it needs a little time to mature a bit but using it even now can give you a decent toolkit for making GUI. As per the website it supports Android also so many will find it really attractive.
Django is one other choice. Although it is a web framework but using it can also give you a decent GUI. Just check out its tutorial for the admin website.
So I had decided that I will do the Python2 to 3 migration of my code base in April itself and I am glad that I was able to do it by 12th April. Solutions to codechef are still present but I decided to leave them be. If I restart online competitions again then I’ll think about them.
I have been thinking about making a BookMarker. I usually keep a lot of BookMarks and my bookmark bar becomes so messed up that I am just unable to arrange them properly. Yeah I like to keep things clean. I have folders inside folders inside in my bookmark bar… you can probably see how many bookmarks there are. It’s just that currently browsers do not allow good enough management of bookmarks. It gets tough. So I thought to make a bookmarker.
So how to manage bookmarks in a better way? Tags and proper search options. Let everything be flat(or in folders) and let there be tags for managing and searching Links. I understand that there are already many online ways to manage bookmarks but I like to try such things out. Also I have some other related ideas so I thought I would be able to use them if I can control this. Why not try?
I have looked at different ways to make this – PySide, Kivy, django.
I have given up on PySide. I am totally fed up with the documentation that it has. Although there is a really good designer for making the UIs but still the lack of documentation totally puts me off. It is just a collection of links from over the internet so far.
Kivy is looking good and I was seriously considering to use it for this but as this is related to browser and using django will keep it closer to browser. Also a simple startup script can start the browser with the bookmarker up and running.
I had decided that I will port my code from Python 2 to Python 3 and with the help of PyCharm the refactoring that I wanted to do was going completely smoothly. I decided in the middle to try something new. I thought when I was restarting Python then maybe try something new.
While doing this I hit Python 3 limits again. The library support is still not as good as for Python 2. The first problem that I faced was with mechanize library. That was when I was trying to get some automation scripts done for logging into websites as per a schedule. Everyone wastes a lot of time online and I wanted to control it. Had the schedule but just opening websites by webbrowser module was not good enough. Why not use Python to login also? Mechanize was just what was needed. But it didn’t support Python 3. Shit. I found a solution to that. Using Selenium I did a test run and was able to login into http://projecteuler.net/ using my username and password. That I can work with now. But still mechanize might have been easier to work with.
Just 2 days back I had the idea of trying a bit of AI. Maybe a small bot or something? Natural Language processing for intelligent answers maybe? Maybe some simple image recognition. Just the flight of thoughts that come and go every now and then. These are not like anything that I have tried before but what’s the problem with trying? I decided to go with Natural Language processing. Shit again. NLTK – the library needed for this had support for Python 2 only.
I was left thinking whether the advice that I got on Python mailing list for using Python 3 for new software actually good? Why actually did I change to Python 3? UNICODE is not something that I have even messed with once in Python. So why? I installed Python 2 but pip was missing. That’s a good thing that they did in Python 3,4, not that it actually helps with half of things not supporting Py3.4 yet.
Anyways I just noted down the ideas that came and decided to thing a bit more before going further. Hope someone reads it and decides to not go with “newest and latest” unless they have the time to port libraries as well.
I had started Python with the main aim of breaking into functional programming. Had read someplace wrong that Python is functional programming language. The time spent on learning it and using it was great. I didn’t get what I started out for but learned the ease of using a high level language and a dynamic one. Coming from mainly C background that changed my perspective a lot about programming.
I decided to try it once more, functional programming. This time I am going with Haskell which is said to be the ultimate functional programming language. Let’s see how far I can get. For the 1-2 days that I have actually tried using Haskell it has been a weird experience. In a good way. It’s different somehow. Couldn’t place how.