Sum of elements in list in Prolog

Recently I noticed that my prolog skill is becoming rusty for not putting it work for very long. For this reason, I’m going to randomly write some prolog snippets here and there. Let’s started with one predicate called “sum_list” which calculate the value of all elements in a list. % The sum of all elements in list in prolog % empty list list_sum([], 0). list_sum([Head | Tail], TotalSum) :- list_sum(Tail, Sum1), TotalSum is Head + Sum1. To run/test the above code, save it to a file called: list_sum.pl, fire-up your prolog interpreter and load it. In my case, I use swi-prolog. Here is the sample output: ...

February 4, 2007 · 1 min · 133 words · kenno

ចងក្រង RPM ពី Source RPMs

ជាធម្មតា ពេលខ្ញុំបញ្ចូល កញ្ចប់ថ្មីៗក្នុងអូផិនស៊ូស៊ី បើសិនជាមិនអាចរក binary rpm បានទេ ខ្ញុំតែងតែចងក្រង (compile) កញ្ចប់ទាំងនោះពីកូដប្រភពដើម។ កូដប្រភពដើម អាចត្រូវបានខ្ចប់ជា tar.gz ឬ .src.rpm។ ក្នុងករណីទីមួយ យើងគ្រាន់តែពន្លា កូដប្រភពដើម រួចបញ្ជា ./configure, make និង make install ជាធម្មតា។ ពេលនេះ ខ្ញុំសូមលើកយក វិធីចងក្រងកម្មវិធី ជាមួយនឹង កូដប្រភពដើម ខ្ចប់ជា .src.rpm។ $ rpmbuild -clean -rebuild packagename.src.rpm ក្រោយពីបាន វាយពាក្យបញ្ជាខាងលើហើយ កញ្ចប់ binary RPM នឹងត្រូវបានបង្កើតក្នុង subdirectory នៃ ថត /usr/src/packages/RPMS/។ សូមពិនិត្យមើល ក្នុងថតដែលមានឈ្មោះ ចាប់ផ្តើមដោយអក្សរ i\*** ឧទាហរណ៍ i386 ជាករណីរបស់ម៉ាស៊ីនខ្ញុំ។

December 19, 2006 · 1 min · 54 words · kenno

Enable Khmer Unicode support on Firefox

With fresh installation of SuSE Linux 10.1 or openSUSE 10.2, Firefox does not display Khmer Unicode font properly. However, there is a very easy fix, all you have to do is to add the “MOZ_ENABLE_PANGO=1” to your .profile. Go to your home directory, then edit the .profile file. I use vi (vi .profile) Scroll down to the last line of the file and add: export MOZ_ENABLE_PANGO=1 Save the .profile file, in my case I do (ESC, SHIFT+Z+Z). Restart the Firefox. Voilla! It’s done and the Firefox should display Khmer Unicode font nicely and correctly now.

December 13, 2006 · 1 min · 95 words · kenno

ស្ថាបនា និង ដំឡើង បានស៊ី លើ​ ស៊ូសាលីណាក់ ១០.១

ដោយ Magnus Hoglund ប្រសិនបើលោកអ្នកបានដំឡើង កំណែចាស់របស់បានស៊ី សូមចាប់ផ្តើមដោយលុបវាជាមុនសិន។ ដំឡើងកញ្ចប់ទាំងនេះ (ដោយប្រើ Yast)៖ mono-develop monodoc-core sqlite-devel libmusicbrainz-devel gstreamer010-devel libgnomeui-devel gnome-desktop-devel nautilus-cd-burner-devel យកកំណែថ្មីបង្អស់របស់ បានស៊ី ពី http://banshee-project.org។ ក្នុងសាច់រឿងនេះ កំណែចុងក្រោយគឺ ០.១១.២។ ទាញយកឯកសារ៖ banshee-0.11.2.tar.gz banshee-offical-plugins-0.11.2.tar.gz ស្រាយ បានស៊ី (banshee-0.11.2.tar.gz) ទៅថតបណ្តោះអាសន្នមួយ។ $ tar xzvf banshee-0.11.2.tar.gz បើកស្ថានីយ៍មួយ ក្នុងថតនេះ ហើយរត់៖ $ ./configure $ make ប្តូរទៅជាឫស (su) រួចរត់៖ $ make install ចេញទៅជាអ្នកប្រើធម្មតា និង ចាប់ផ្តើម បានស៊ី $ /usr/local/bin/banshee & ការដំឡើង plugins របស់ បានស៊ី អាចធ្វើបានដោយវិធីដូចគ្នា។ ក្នុងករណីរបស់ខ្ញុំ ខ្ញុំបានស្រាយ banshee-offical-plugins-0.11.2.tar.gz និងរត់ ពាក្យបញ្ជាដូចខាងលើ (មានន័យថា៖ ./configure; make; make install)នេះជាការស្រេច សូមរីករាយសប្បាយជាមួយបានស៊ី! ...

December 6, 2006 · 1 min · 84 words · kenno

Play Midi file on Linux

If you want to play midi file on Linux, SuSE for example, you need the midi player. Amarok or some other players such as Banshee couldn’t play midi at all. I am not sure why, however, I found a command-line application called Timidity. It can be downloaded from http://download.opensuse.org/distribution/SL-10.1/inst-source/suse/i586/timidity-2.13.2-21.i586.rpm. Once installed, you can play it by issuing this command timidity file_name.midi. Here is an example running timidity to play what4.midi: kenno@localhost:~/> timidity what4.mid Requested buffer size 32768, fragment size 8192 ALSA pcm ‘default’ set buffer size 32768, period size 8192 bytes Playing what4.mid MIDI file: what4.mid Format: 1 Tracks: 5 Divisions: 480 Sequence: Track name: Track 1 Track name: Guitar 2 Track name: Track 3 Track name: Percussion Playing time: ~26 seconds Notes cut: 0 Notes lost totally: 0 Enjoy the midi tune!

November 17, 2006 · 1 min · 133 words · kenno