This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn summit(vec:&Vec<i64>) -> i64 | |
{ | |
let mut sum = 0i64; | |
for x in vec { sum = sum + x }; | |
return sum; | |
} | |
fn main() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin 764 foo.h5 | |
MB4A$1@T*&@H```````@(``0`$`````````````````#__________YX5```` | |
M````__________\``````````&```````````0````````"(`````````*@" | |
M`````````0`!``$````8`````````!$`$```````B`````````"H`@`````` | |
M`%12144```$`_____________________P``````````5A0````````(```` | |
M```````````````````````````````````````````````````````````` | |
M```````````````````````````````````````````````````````````` | |
M```````````````````````````````````````````````````````````` | |
M```````````````````````````````````````````````````````````` | |
M```````````````````````````````````````````````````````````` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module OrdList (empty, fromList, insert, toList, OrdList) where | |
import Data.List as L (span) | |
data OrdList a = OrdList [a] deriving (Show) | |
empty :: OrdList a | |
empty = OrdList [] | |
insert :: (Ord a) => a -> OrdList a -> OrdList a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Suppose I want to use an argument twice, as for example in the expression: | |
(\x -> (pred1 x) and (pred2 x)) | |
Is there a shorter way of doing this? | |
liftA2 (&&) pred1 pred2 | |
You can be cute and use the applicative instance on functions: | |
(&&) <$> pred1 <*> pred2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/mcarter/.local/bin/octave-cli -qf -W | |
# -*- octave -*- | |
1; | |
h5name = "/home/mcarter/temp.h5" | |
printf("Hello world\n"); | |
pkg load hdf5oct | |
data = h5read(h5name, "/D20151113/rs6mb"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Desktop entry for dillo. | |
# System wide install as /usr/share/applications, or /usr/local/share/applications | |
# Private install as $HOME/.local/share/applications | |
# See http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.0.html | |
# See http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html | |
[Desktop Entry] | |
Version=3.0.5 | |
Type=Application | |
Name=Dillo web browser | |
GenericName=Web Browser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import Data.List | |
import Language.Haskell.Interpreter | |
main :: IO () | |
main = do r <- runInterpreter testHint | |
case r of | |
Left err -> printInterpreterError err | |
Right () -> putStrLn "that's all folks" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ExampleVersion where | |
{- | |
links: | |
http://stackoverflow.com/questions/9857710/haskell-correct-practice-to-specify-%5Cversion-in-source | |
Be sure to put Paths_packagename in your Other-Modules section of the cabal file. | |
-} | |
import Paths_mypackage (version) -- replace 'mypackage' with you nnn.cabal 'name' tag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loopCollect state0 xs func = fst $ runState (forM xs func) state0 | |
-- result is ["hello", " ", "world"] | |
eg = loopCollect "hello world" [5, 1, 5] | |
(\i -> do | |
str <- get | |
let (h, t) = splitAt i str | |
put t | |
return h) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyDatalog import pyDatalog as pdl | |
# set up some basic terms | |
pdl.create_terms('F,G,Q,what,eat') | |
# F G | |
+what('pork', 'meat') | |
+what('lamb', 'meat') | |
+what('peas', 'veg') | |
+what('beans', 'veg') |