The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Problem solved!
For other Mint 18 users with same problem:

1) Install nodejs (sudo apt install nodejs) Note: it may be installed already, most probably, but I recommend removing it (sudo apt remove nodejs) and install fresh from terminal. Else, there may be all these EACCESS errors, which will lead you straight into the fog!! Cost me 2 days of irritation.

2) install npm (sudo apt install npm)
3install elm (npm install -g elm)
4) Edit the PATH, I appended this sentence to the /etc/profile-file:
With Mint 18 xfce-edition: sudo xed /etc/profile, then add at the end: (in my case) :
export PATH="$PATH:/usr/share/lib/node_modules/elm/Elm-Platform/0.17.1/.cabal-sandbox/bin/"

(Other Linux-versions may use gedit or other text editor instead of xed)

Thanks to Joey Eremondi!

regards, audun
I understand. Thanks for directing me to those fora, surely I will find my answer there!
The executable seems to be here, but the 'elm-make' command is not recognized anywaY.

audun@niflheim ~/.npm-global/lib/node_modules/elm/Elm-Platform/0.17.1/.cabal-sandbox/bin $ elm-make --version
elm-make: no such command
Btw: The 'elm-make' file in the 'binwrappers'-directory is not an executable, only a text-file
I attach an output at the end.
I'm not a Linux-guru either, but I would expect the installation instructions to work for me.

1) I reinstalled Node + npm in one package.
2) The npm config get prefix- command had the output /usr
3) All the rest can be seen in this output. It looks as though Elm is installed, the system cannot find it, jfr the 'elm-make --version' command at the end.

audun@niflheim ~ $ npm config set prefix '~/.npm-global'
audun@niflheim ~ $ NPM_CONFIG_PREFIX=~/.npm-global
audun@niflheim ~ $ npm install -g elm
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
/home/audun/.npm-global/bin/elm-make -> /home/audun/.npm-global/lib/node_modules/elm/binwrappers/elm-make
/home/audun/.npm-global/bin/elm -> /home/audun/.npm-global/lib/node_modules/elm/binwrappers/elm
/home/audun/.npm-global/bin/elm-package -> /home/audun/.npm-global/lib/node_modules/elm/binwrappers/elm-package
/home/audun/.npm-global/bin/elm-reactor -> /home/audun/.npm-global/lib/node_modules/elm/binwrappers/elm-reactor
/home/audun/.npm-global/bin/elm-repl -> /home/audun/.npm-global/lib/node_modules/elm/binwrappers/elm-repl

> elm@0.17.1 install /home/audun/.npm-global/lib/node_modules/elm
> node install.js

Downloading Elm binaries from https://dl.bintray.com/elmlang/elm-platform/0.17.1/linux-x64.tar.gz
elm@0.17.1 /home/audun/.npm-global/lib/node_modules/elm
??? mkdirp@0.5.1 (minimist@0.0.smilie
??? promise@7.1.1 (asap@2.0.4)
??? tar@2.2.1 (block-stream@0.0.9, inherits@2.0.1, fstream@1.0.10)
??? request@2.72.0 (aws-sign2@0.6.0, tunnel-agent@0.4.3, forever-agent@0.6.1, oauth-sign@0.8.2, caseless@0.11.0, is-typedarray@1.0.0, stringstream@0.0.5, aws4@1.4.1, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, tough-cookie@2.2.2, node-uuid@1.4.7, qs@6.1.0, combined-stream@1.0.5, mime-types@2.1.11, form-data@1.0.0-rc4, hawk@3.1.3, bl@1.1.2, http-signature@1.1.1, har-validator@2.0.6)
audun@niflheim ~ $ elm-make --version
elm-make: command not found


And the directory-structure is like this:

home
....
- .npm-global
- bin
- etc
- lib
-node-modules
-elm
-binwrappers
+-Elm-Platform
+ -0.17.1
+-node_modules
...
...

Maybe I somehow only need to tell the system where the 'elm'- commands can be found? But I'm not a Linux-guru.....
The given procedure for changing access permission for npl doesnt work. The prefix command says /usr/local, but in reality the directory is elsewhere, only represented by a link to the real directory. Ive tried to substitute the location in the command, but it seems the file structure is different too.

Maybe uninstalling node and npl, and reinstallasjon together from the Node Web site?
The weather-service has changed its API. When I try "http://api.openweathermap.org/data/2.5/weather?q=Singapore", I get this response:
Q: API calls return an error 401

A: Starting from 9 October 2015 our API requires a valid APPID for access. Note that this does not mean that our API is subscription-only now - please take a minute to register a free account to receive a key.

We are sorry for inconvenience but this is a necessary measure that will help us deliver our services to you faster and more reliably.

For FOSS developers: we welcome free and open source software and are willing to help you. If you want to use OWM data in your free software application please register an API key and file a ticket describing your application and API key registered. OWM will review your request lift access limits for your key if used in open source application.


The code for the request call may need to be changed to include a personal key?

-audun
Yes, you're right!

After deleting the source-file and the beam-file, it worked as you said.

I must have forgotten to save the 'title'-version and worked on the [title]-version unknowingly.

- audun
...and lastly: the list ends in [] :

iex(9)> [h|t] = ["Dentist", "Doctor"]
["Dentist", "Doctor"]

iex(10)> t
["Doctor"]

iex(11)> [h|t] = ["Doctor"]
["Doctor"]

iex(12)> t
[]                          #  <-  Last element of the list
I'm not sure I understand (but I still haven't read about improper lists).
But when I run the program inserting simple 'title' (not [title]), it runs like this:
iex(1)> c "simple_todo.exs"
simple_todo.exs:1: warning: redefining module TodoList
[TodoList]

iex(2)> newlis = TodoList.new()
#HashDict<[]>

iex(3)> newlis2 = TodoList.add_entry(newlis,{2015,11,05},"Doctor")
#HashDict<[{{2015, 11, 5}, ["Doctor"]}]>

iex(4)> newlis3 = TodoList.add_entry(newlis2,{2015,11,05},"Dentist")
#HashDict<[{{2015, 11, 5}, ["Dentist", "Doctor"]}]>

iex(5)> newlis3 = TodoList.add_entry(newlis3,{2015,11,05},"Vet")    
#HashDict<[{{2015, 11, 5}, ["Vet", "Dentist", "Doctor"]}]>
    
iex(6)> [head|tail] = TodoList.entries(newlis3,{2015,11,05})
["Vet", "Dentist", "Doctor"]
iex(7)> head
"Vet"

iex(8)> tail
["Dentist", "Doctor"]  # <- Both a head and a teil. Looks like a normal list to me ??
iex(9)> 
Oh, another question: I do a small change:
def add_entry(todo_list, date, title) do
    HashDict.update(
      todo_list,
      date,
      title,                                       [b]# <- simple 'title' instead of [title][/b]
      fn(titles) -> [title | titles] end
    )
  end


If one permist entering a list of titles, the result of TodoList.entries(....) becomes ugly: not simply a list of entries, but probably also a list of simple entries mixed with lists of entries: e.g.
[["bookmaker","Vet"], "Dentist",.....]

Just a comment.
- audun
Of course ! Shame on me, I should have figured out that!
Thanks for quick reply! (Very nice book, btw)

audun
What do I do wrong? I paste in the code from my own editor,
it should be identical to the book listing:
defmodule TodoList do
  def new, do: HashDict.new

  def add_entry(todo_list, date, title) do
    HashDict.update(
    todo_list,
    date,
    [title],
    fn(titles) -> [title | titles] end
    )
  end

  def entries(todo_list, date) do
    HashDict.get(todo_list, date, [])
  
  end
end


Then, I run:

iex(1)> c "simple_todo.exs"
simple_todo.exs:1: warning: redefining module TodoList
[TodoList]

iex(2)> mylist = TodoList.new()
#HashDict<[]>

iex(3)> TodoList.add_entry(mylist,{15,11,06},"Dentist")
#HashDict<[{{15, 11, 6}, ["Dentist"]}]>

iex(4)> mylist
#HashDict<[]> // What? mylist is empty?

iex(5)> TodoList.entries(mylist,{15,11,06})
[] // mylist hasn't been populated !!
I'm stuck here.

It looks like the PATH is set correctly.
Scala reads the file, but fails with 4 errors.

I have strictly followed the Appendix A.

So what's wrong??

mvh
audun
First, from the root directory I execute the command with a path to the fat.jar-file.
This is danzone's command, with the only exception that my version is a little different (...2.2.1.0... instead of 2.2.2.20)

C:scalac -cp C:Usersantnfigaro_2.2.1.0-2.11figaro_2.11-2.2.1.0-fat.jar Test.scala <enter>

error: no access
one error found.


Then I omit the -cp and includes the path in the command:

C:scalac Usersantnfigaro_2.2.1.0-2.11figaro_2.11-2.2.1.0-fat.jar Test.scala <enter>


error: IO error while decoding figaro_2.11-2.2.1.0-fat.jar with UTF-8
Please try specifying another one using the -encoding option
one error found

I've also changed directory and tried execution in the figaro...2.2.1.0-directory, which not surprisingly produces the same response:

C:Usersantnfigaro_2.2.1.0-2.11scalac figaro_2.11-2.2.1.0-fat.jar Test.scala <enter>

error: IO error while decoding figaro_2.11-2.2.1.0-fat.jar with UTF-8
Please try specifying another one using the -encoding option
one error found


Then I look at the file properties of figaro...-fat.jar, but there's nothing there on changing encoding.

I've tried to google character encoding in windows, but that seems to be a nasty business.
I thought, btw, that the windows default encoding was UTF-16.

I will try all this on Linux instead, but of course any tips on windows execution are welcome.

In the process, I found out that localized windows-systems (Norwegian, probably Italian..) results in a lot of confusion regarding the naming of file paths. It is possible, though, to revert to the original directory names. Example: on my machine 'Users' is called "Brukere' in the native tongue, but under the hood, I have to write 'users' anyway. Pheew! Windows!

cordially
audun
Well, thanks both of you. I read this at work, will try you advices later. I begin to understand the problem better now.

Actually, I use Linux Mint on a daily basis, but presently I have only tried it on my workplace windows-machine.

cordially
audun
I have unpacked the figaro download in the scala directory, and set the classpath accordingly:


C:>echo %CLASSPATH%
Csmilierogram Files (x86)scalafigaro_2.2.1.0-2.11


Then I copied and pasted the Test.scala file from the appendix A (MEAP version 2) to the figaro directory (scalafigaro_2.2.1.0-2.11Test.scala).

Since the scala(2.11) system is on the Path, I executed the Test file, like this:


C:>scalac Test.scala
Test.scala:1: error: object cra is not a member of package com
import com.cra.figaro.language._
^
Test.scala:2: error: object cra is not a member of package com
import com.cra.figaro.algorithm.sampling._
^
Test.scala:5: error: not found: value Constant
val test = Constant("Test")
^
Test.scala:6: error: not found: value Importance
val algorithm = Importance(1000, test)
^
four errors found


So, where can the system find the "object.cra...."-imports? The figaro.zip seemed to contain only one simple directory with a few jar- and corresponding javadoc ascii-files.
What is the "package com" ??

cordially
Audun