LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Blogs > Bits and Pixels
User Name
Password

Notices

Concerning free software, programming, and whatever else I find interesting. Also the blog for my Web site, frigidcode.com.
Old

C++ had lambda functions!

Posted 01-31-2013 at 01:21 AM by hydraMax (Bits and Pixels)

I'm doing a CS class which forces me to use C++. I was not very excited about this. However, I have recently be greatly encouraged by the discovery that C++ does, in fact, have lambda functions (or, more properly, anonymous functions) at least in the C++11 standard:

https://en.wikipedia.org/wiki/Anonym...ctions#C.2B.2B

Basically, the big deal here is that I can construct new functions /inside/ of other functions, and even capture variables from the context. This,...
Member
Posted in Uncategorized
Views 437 Comments 0 hydraMax is offline
Old

Quick and dirty plotting with Haskell: Supplement

Posted 01-14-2013 at 11:54 PM by hydraMax (Bits and Pixels)

I just wanted to add a brief note to my previous post: It is also quite simple to do a plot with multiple functions. The following code gives the graph seen in the attached PNG:

Code:
h> import Graphics.Gnuplot.Simple
h> let f x = 3 - 2*x + 4*x**2
h> let g x = 8*x - 2
h> let h a x = g a * (x - a) + f a
h> plotFuncs [] (linearScale 1000 (-10,10)) [f, g, h (-5)]
f(x) is a function, g(x) is the derivative of f(x), and...
Attached Images
File Type: png plotFuncs.png (49.5 KB, 4 views)
Member
Posted in Uncategorized
Views 500 Comments 0 hydraMax is offline
Old

Installed Nix

Posted 01-09-2013 at 01:49 PM by hydraMax (Bits and Pixels)
Tags nix

I recently installed the Nix package manager on my system:

https://nixos.org/nix/

Nix is an intriguing idea: a purely functional and deterministic package management system. Nix allows you to install, upgrade, and remove packages on your system without ever having to worry about breaking the dependencies of other packages already installed on your system. This is impossible, by design. Likewise, after installing new packages, you are free to roll back those changes...
Member
Posted in Uncategorized
Views 405 Comments 0 hydraMax is offline
Old

haskell: get lines and handle end of file

Posted 01-01-2013 at 02:23 AM by hydraMax (Bits and Pixels)
Updated 01-01-2013 at 02:27 AM by hydraMax
Tags haskell

I thought I'd post this convenience function, since I didn't see an obvious one in base:

Code:
import Prelude hiding (catch)
import Control.Exception
import System.IO.Error hiding (catch)

readl f = catch (getLine >>= return . Just)
                (\e -> if (isEOFErrorType . ioeGetErrorType) e
                         then return Nothing
                         else ioError e)
          >>= \a -> case a of
...
Member
Posted in Uncategorized
Views 680 Comments 0 hydraMax is offline

  



All times are GMT -5. The time now is 08:57 AM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration